[antlr-interest] Rewrite rule ambiguity(newbie)
ali azimi
aliaazimi at yahoo.com
Wed Jul 18 18:02:15 PDT 2007
Hi,
Thank you very much in advance.
I have a rule which causes some errors (e.g. outOfMemory errors). The rule is:
r : 'block' q? b COMMA
( c | e )* ( f | g ) ?
'endblock' ( q ? b ) ? COMMA
;
Could you please give your opinion as to whether the following two options are correct?
OptionA:
r : 'block' q? b COMMA
(L1^ c* f? |L2^ c* g? |L3^ e* f? |L4^ e* g?)
'endblock' q ? b ? COMMA
;
OptionB:
r : r1 | r2
;
r1 : 'block' q1=q? b1=b COMMA c* ( f? 'endblock' (q2=q? b2=b)? COMMA
-> ^( 'block' $q1? $b1 c* f? 'endblock' (BLOCK $q2? $b2)? )
| g? 'endblock' ( q3=q? b3=b)? COMMA
-> ^( 'block' $q1? $b1 c* g? 'endblock' (BLOCK $q3? $b3)? )
);
r2 : 'block' q1=q? b1=b COMMA e* ( f? 'endblock' (q4=q? b4=b)? COMMA
-> ^( 'block' $q1? $b1 e* f? 'endblock' (BLOCK $q4? $b4)? )
| g? 'endblock' (q5=q? b5=b)? COMMA
-> ^( 'block' $q11? $b11 e* g? 'endblock' (BLOCK $q5? $b5)?)
);
Very much appreciated.
Best regards,
Al
---------------------------------
Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070718/7b104d39/attachment-0001.html
More information about the antlr-interest
mailing list