[antlr-interest] Navigate through the parsed Tree

Lucaz lucazd at gmail.com
Fri Jul 11 16:43:06 PDT 2008


I guess this is a solution for the people interested in traversing the
ANTLRWork parsed tree:

*your start rule*
@after {
    Tree root = retval.getTree();
}
:
...
;

Tree API:
http://www.antlr.org/api/Java/interfaceorg_1_1antlr_1_1runtime_1_1tree_1_1_tree.html


On Fri, Jul 11, 2008 at 2:17 PM, Lucaz <lucazd at gmail.com> wrote:

> Hello, I am very new with ANTRL and I would like to try something simple:
> I am using ANTRLWork and the Java 1.5 grammar file (
> http://www.antlr.org/grammar/1152141644268/Java.g).
> My question is; how can I access the parsed tree?.
>
> I tried getTree(), but it returns null. The adapter (getAdapter()) works
> but I don't understand what should I pass to its methods (like
> getParent(Object)).
> (I've checked the docs here ->
> http://www.antlr.org/api/Java/interfaceorg_1_1antlr_1_1runtime_1_1tree_1_1_tree_adaptor.html#01954069ab7d2c2eb78d328572110725
> )
>
> I tried these options also: output=AST; ASTLabelType=CommonTree;
>
> Thanks a lot for this awesome tool!,
> Lucaz
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080711/b17673cd/attachment.html 


More information about the antlr-interest mailing list