[antlr-interest] Rewrite rule for multiple alternatives
ali azimi
aliaazimi at yahoo.com
Thu Aug 2 05:58:50 PDT 2007
Hi,
I would do the following:
rule: lc='{' subRule* '}' -> ^(COMPOUND[$lc,"COMPOUND"] subRule*)
;
subRule
:a
|b
|c
;
Best wishes,
Al
Jan Obdrzalek <obdrzalek at gmail.com> wrote:
Hi,
what is the correct way to write this rewrite rule?
: '{' (a | b | c)* '}' -> ^(COMPOUND (a | b | c)*)
I.e. I want to have a tree with the root COMPOUND and with the children given by the rules a,b,c in the original order. ANTLRv3 does not like my intuitive notation :( And I do not want to change the grammar much. The examples in the book are all a little bit different (unless I missed some).
Thanks for all suggestions,
Jan
---------------------------------
Shape Yahoo! in your own image. Join our Network Research Panel today!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070802/e995f2b8/attachment.html
More information about the antlr-interest
mailing list