[antlr-interest] Manual Tree Walking Vs. Tree Grammars

Amr Muhammad amr.muhammad.w at gmail.com
Tue Nov 2 12:48:45 PDT 2010


Hello,

In this post : http://www.antlr.org/pipermail/antlr
-interest/2010-October/039862.html
The following was mentioned:

> Also, remember to only call external Helper methods from your parsers/tree
> walkers. Do not embedded any code other than the calling code and pass the
> whole tree or token pointer. This means your calls won't care what gets done
> by the helper API and the helper API will not care how the parsers decided
> to call it. Anything else is an unmaintainable mess.
>
>
So,
does this imply that it is easier to walk the AST manually rather than
embedding actions in the tree grammar ?

Based on what i have tried till now, it seems that getting the embedded
actions to work, as expected, is not easy. So, I'd like to know if there is
some benefit that I would get out of writing embedded actions in tree
grammars?

Also, there is this post that seems to advocate manual tree walking:
http://www.antlr.org/article/1170602723163/treewalkers.html

So, I'm confused as to whether continue trying to make tree grammars do what
I want, or switch to manual tree walking. Appreciate your guidance...

Thank you for your time :)
Best Regards,

Amr Muhammad
Cairo Univ. Computer Eng. Grad.
twitter:@amrmuhammad <http://twitter.com/amrmuhammad>


More information about the antlr-interest mailing list