[antlr-interest] Tree parser and Java interface question to passing rule results
Thomas Bernhardt
bernhardttom at yahoo.com
Thu Jan 3 09:26:29 PST 2008
I found that in order for the "$constant.tree" to work, I have to turn on "output=AST" in my tree grammar. If I add "output=AST" then the generated tree walker doesn't compile:
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
with "retval.stop" cannot be found as a symbol variable, since the result inherits from TreeRuleReturnScope and that doesn't have a member stop. There are other compiler errors.
Thanks,
Tom
----- Original Message ----
From: Terence Parr <parrt at cs.usfca.edu>
To: Thomas Bernhardt <bernhardttom at yahoo.com>
Cc: antlr-interest at antlr.org
Sent: Wednesday, January 2, 2008 5:43:49 PM
Subject: Re: [antlr-interest] Tree parser and Java interface question to passing rule results
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
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080103/9554fb62/attachment.html
More information about the antlr-interest
mailing list