[antlr-interest] [C Target] Bug in AST walking , implementing control flow

Mohamed Yousef harrrrpo at gmail.com
Mon Oct 26 22:42:14 PDT 2009


Hi,
on trying to implement control flow , in an AST walker grammar
following this example :
http://www.antlr.org/wiki/display/CS652/Tree-based+interpreters

ifstat
    :   ^('if' c=expr s=. e=.?) // ^('if' expr stat stat?)


in the C target the problem is that in the generated code , variables e,s
are not defined! (yet they are assigned values )
and the compiler complains about that , when i do define them by hand (under
the definition of variable c  )
the code compiles fine
so is this really a bug or i'm misusing ? any applicable workarounds ?
----
i have another question regarding control flow in c target
to get the index of say c in above example i write
c.tree->getToken(c)->index ,, right ? i can then SEEK to thins index , and i
can save
it in a symbol table , and it will be valid across different tree walks
(walk filling symbol table and
the walk that really interprets code )  ,, right ?

Thanks,
Mohamed Yousef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091027/305648c7/attachment.html 


More information about the antlr-interest mailing list