[antlr-interest] a left recursive walker rule
Loring Craymer
lgcraymer at yahoo.com
Fri Jul 14 23:32:33 PDT 2006
This looks very weird--you have no termination condition for the recursion. Normally, recursive rules have termination conditions and the recursion-to-iteration conversion is relatively straightforward. I cannot easily imaging how you got to this form. What did the annotated parser rule look like that got you here?
--Loring
"��͸� Jigang (Robert) Sun" <sunjigang1965 at yahoo.com.cn> wrote: Hi,
I have a rule in tree walker, which is left recursive: A : (A|B)+ C ,
so I am trying to eliminate it
A : (A|B)+ C
=> A : ( A(A|B)* | B(A|B)*) C
=> A : A(A|B)* C | B(A|B)* C
=> A : B(A|B)* C ((A|B)* C)*
=> A : B ( (A|B)* C )+
=> A : B ( ( B((A|B)* C)+ |B )* C )+ //replace A with " B ( (A|B)* C )+ "
=> A : B( ( B [((A|B)* C)+ | ]* C)+ // need to replace A with " B ( (A|B)* C )+ " again
=> A : ... //then again and again forever, never ends
Any better solution?
Thanks
Jigang
___________________________________________________________
���������-3.5G�����20M����
http://cn.mail.yahoo.com/
---------------------------------
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail Beta.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060714/ee2846a7/attachment.html
More information about the antlr-interest
mailing list