http://lists.gnu.org/archive/html/help-bison/2009-01/msg00001.html
the simplest assembler sasm cannot handle forward references. We can use single pass but it is too complicated. Inspired by articles such as the above, I attempted 2 pass.
Just add a global variable pass and repeat yyparse().
inside the code generator, if pass = 2, then do the code generation, otherwise just increment PC.
int pass=1;
yyparse();
pass=2;
yyparse;
Alternatively,
just repeat yyparse twice. You will get 2output. just discard the first one.
yyparse();
yyparse();
No comments:
Post a Comment