[antlr-interest] Rewriting with nodes from sub-rules?
Foust
javafoust at gmail.com
Wed Jul 30 16:38:55 PDT 2008
edA-qa mort-ora-y wrote:
> I wish to work with the tokens of the sub-rules in the
> rewrite. It isn't clear from the book if this is possible.
I've also had a desire to do that, but couldn't find a way. I wanted to set a synthetic token, using a token from a previous rule. So using your example, if SET is a synthetic token, I was trying to create it with the same context information as a token from a previously matched rule, such as:
... -> ^(SET[nameValue.name] ...)
It doesn't appear that we have access to a previous rule's tokens using this syntax.
-Brent
------
>
> For example:
>
> exprA : 'set' nameValue;
> exprB : 'define' nameValue;
> nameValue : name value;
>
> I would like to have a rule like this:
> exprA : 'set' nameValue -> ^(SET nameValue.name nameValue.value)
More information about the antlr-interest
mailing list