2021年5月4日星期二

How to make a parse function receiving string as argument regarding lex and yacc?

I want to write a parser that provides API like const char *convertA2B(const char *input). It looks like:

  1. lex_and_yacc(input) -> myADT
  2. myADT.intepret() -> ouptut

In yacc, there's int yyparse(void), it seems relying the yyin varaible. Is there any way I can directly parse a string, without these magical global variables?

https://stackoverflow.com/questions/67394676/how-to-make-a-parse-function-receiving-string-as-argument-regarding-lex-and-yacc May 05, 2021 at 11:06AM

没有评论:

发表评论