[antlr-interest] Rule rewrite confusion!
xkrebstarx
xkrebstarx at gmail.com
Sat Aug 11 14:51:56 PDT 2007
Hey everybody,
The problem in general is a production of the form, where A,B,C,X,Y,Z are
either non-terminals or terminals and the ^ attribute indicates that we
would like this terminal or non-terminal to be the root of the AST
A : B ( X^ | Y^ | Z^ ) C
;
where
X : X -> ^(IMAGINARY_NODE X)
and I would like to include the IMAGINARY_NODE as part of production A and
not of production X.
A production like this is a problem when writing the AST since we must
specify the AST's form after the rule, like this...
A : B ( X | Y | Z ) C
-> ^( (IMAGINARY_NODE X)|Y|Z ) B C
;
However, we cannot have a choice in a rewrite as the root node for an AST.
We can write the rewrite mid-rule, like this...
A : B ( X -> ^(IMAGINARY_NODE X B C)
| Y -> ^(Y B C)
| Z -> ^(Z B C)
) C
;
X : X
;
but we do not know what C is yet.
How can this be fixed?
Thanks,
xkrebstarx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070811/cf8531bf/attachment.html
More information about the antlr-interest
mailing list