[antlr-interest] is there any standard tree?

Terence Parr parrt at cs.usfca.edu
Thu Jun 7 11:49:53 PDT 2007


"depth first walk" is  your keyword search.  Each node is a simple  
list of children.

I think you are also asking how to make a tree that is not a flat  
linked list.  Use rewrite rules and possibly ! and ^ operators.  See  
examples.  Easy. :)

Ter
On Jun 7, 2007, at 9:38 AM, Markus Kuhla wrote:

> Is this too simple or too stupid? Don't hesitate to answer ;)
>
> cheers
>
>> 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. Where are the other  
>> nodes
>> between root and leafs? I also tried:
>> CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
>> nodes.setTokenStream(tokens);
>>
>> But nodes.toString() also returns only the tokens. Is there any  
>> way to get
>> the entire AST, without writing a new grammar for a tree walker?
>>
>>
>> Thank you very much for any reply !!!
>> Best, Markus
> -- 
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser



More information about the antlr-interest mailing list