|MULTI PARSING FILE email@example.com (1992-08-02)|
|From:||firstname.lastname@example.org (A. Walker)|
|Organization:||Monash University, Melb., Australia.|
|Date:||Sun, 2 Aug 1992 23:40:14 GMT|
Currently I have implemented an awk to C compiler. It needs to
parse the awk source file twice: once to collect and type undeclared
symbols and then to compile the awk source to C. So far this is
implemented by calling yyparse() and then calling yyrestart() in lex,
rewind(yyin) and calling yyparse() again. This works fine using BYACC and
FLEX. However when using BISON (for portability on other platforms)
yyparse() cannot be called a second time, it results in 'parse error'. How
and a BISON (v1.11, v1.18) parse be 'restarted'?
As an alternative i tried creating a lex yywrap() to intercept the first
EOF, and restart. But this results in an incomplete first parse,
presumably because yyparse() is lagging a few tokens behind and _needs_ to
see EOF to complete parsing.
What is the standard approach to parsing a source file multiple times?
If all works out well I'll make this shareware.
[Bison is supposed to let you restart a parse by calling yyparse() again.
You may either have a bison bug or an assumption of some sort in your code.
But since yyrestart() is specific to flex, why not just tell people to use
flex and byacc and leave it at that. You can distribute their C output for
people who don't have them on the target machine. -John]
Return to the
Search the comp.compilers archives again.