[antlr-interest] Tree parsers and real world example

Micheal J open.zone at virgin.net
Sun Apr 29 09:36:28 PDT 2007


Hi,

> ANTLR (2.x) is being used in several compiler projects: 
> http://seclib.blogspot.com/2005/06/parser-generator-used-for-popular.html
> 
> You can check their source code to see how they handle it.
> 
> For simple language, you can embed code generator in the semantic 
> actions of treeparser (even parser). In my own project (XRuby), I used 
> treeparser to turn ANTLR's AST into a DOM-like structure, then use 
> Visitor approach to generate bytecode:
http://xruby.googlecode.com/svn/trunk/src/com/xruby/compiler/parser/ruby.tre
e.g

The intermediate AST-to-DOM step sounds like it would require extra
resources compared to simply processing the original AST. Was this the case
for you?

Why did you choose this design over just using treeparser(s) to walk the
ANTLR AST?

Did you consider using custom AST nodes (and manual tree generation actions)
that your visitors could use directly?


Micheal

-----------------------
The best way to contact me is via the list/forum. My time is very limited.



More information about the antlr-interest mailing list