[antlr-interest] postmortem

Andy Tripp antlr at jazillian.com
Thu Mar 13 13:29:30 PDT 2008


Loring Craymer wrote:

> 
> For practical translation, though, parse trees are not particularly 
> helpful--they capture preconceptions about the input language and 
> contribute little to the analysis phase(s) of a translator.  Failure to 
> design a tree structure that helps in performing analysis seems 
> invariably to lead to "action-packed" grammars that become less and less 
> maintainable as they are asked to do more and more.  Eventually, you get 
> to the point where the grammar itself is virtually unmaintainable 
> because it is hidden by a vast amount of target language code.

Yea, I'm sure that would become a huge mess very quickly.

But suppose you design things so that the parser just parses (producing an AST) and does not
try to do any translation. And similarly, suppose you don't try to define
a treewalker to do translation, because that's going to have this
"huge amounts of code buried within a grammar" problem anyway.

Instead, you just have some ("by hand") code that walks the AST.
Wouldn't that code be straightforward, simply ignoring any nodes that it
doesn't need to process? For example, look at my thing that just
walks a Java AST "by hand" and pretty prints it:
http://www.jazillian.com/articles/JavaEmitter.java
Seems like this wouldn't be much more complicated to deal with a parse tree
than it is now dealing with an AST.


More information about the antlr-interest mailing list