[antlr-interest] Newbie tree rewrite question.

Andy Tripp antlr at jazillian.com
Tue Jul 3 10:06:35 PDT 2007


Having multiple passes over an AST is certainly doable, but I haven't 
seen any specific examples
and documentation.

You might find this article interesting: 
http://www.jazillian.com/articles/treewalkers.html
where I talk about using ANTLR to walk the AST vs. doing it "by hand". 
If things get complicated
enough, you could look into tools like TXL http://www.txl.ca/

Also, in case you haven't seen it, all of Chapter 8 "Tree Grammars" in 
the ANTLR v3 book
us about tree grammars.

Andy

William Halliburton wrote:
>
> Hello,
>
> I have a grammar that parses a C like language into an AST and a tree 
> grammar that traverses the AST and outputs a translated language via 
> templates.
>
> My tree grammar is getting a little complex and i think that things 
> could be simplified by having a second pass grammar that translates 
> the AST into a similar AST before the final tree grammar.
>
> I've been trying figure out how to make a simple AST to AST tree 
> parser. Is this desirable and doable? Are there any examples? Looks 
> like the rewrite=true option works with templates not AST.
>
> Thank you,
> William Halliburton



More information about the antlr-interest mailing list