[antlr-interest] Tree parser and Java interface question to passing rule results

Terence Parr parrt at cs.usfca.edu
Wed Jan 2 14:43:49 PST 2008


Hi.
On Jan 2, 2008, at 12:39 PM, Thomas Bernhardt wrote:

> Can someone please help me get a tree walker to invoke a Java method  
> for a rule, passing the tree node representing the rule result?
>
> I have the tree grammar as follows, and the "???" is what I'm trying  
> to figure out:
>
> valueExpr
>     :     constant { leaveNode(???); }
>     |      // ...
>     ;
>
> constant
>     :    INT_TYPE
>     |    LONG_TYPE
>     |    FLOAT_TYPE
>     |    DOUBLE_TYPE
>     |    STRING_TYPE
>     |    BOOL_TYPE
>     |    NULL_TYPE
>     ;
>
> The goal is to get the tree or node that resulted from the  
> "constant" rule to be passed to the "leaveNode(Tree tree)" method.  
> What should "???" be?

$constant.tree

Ter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080102/5f3156eb/attachment.html 


More information about the antlr-interest mailing list