[antlr-interest] is there any standard tree?

Randall R Schulz rschulz at sonic.net
Thu Jun 7 11:38:33 PDT 2007


On Wednesday 06 June 2007 11:16, Markus Kuhla wrote:
> Hi,
>
> I want to get the AST from the parser. I set the option "output=AST;"
> and saved the return object from the parser.
>
> Now I would like to walk (DFS) through the tree. But using the
> getChild(i) method gives me only the tokens of the leafs. ...
>
> ... Is there any way to get the entire AST, without writing a new
> grammar for a tree walker?

I think the basic fact is there is no single, unique or meaningful 
default for how to produce an abstract syntax tree from the parse tree 
(which _is_ explicitly and uniquely defined by the grammar 
productions).

Thus you must write all the transformations that define how to construct 
the AST from the productions of the grammar.


> Thank you very much for any reply !!!
> Best, Markus


Randall Schulz


More information about the antlr-interest mailing list