[antlr-interest] Problems with AntlrWorks 1.0b11

Gavin Lambert antlr at mirality.co.nz
Tue May 8 12:53:50 PDT 2007


At 04:17 9/05/2007, Shmuel Siegel wrote:
>I created the following grammar to study the elimination of left 
>recursion. I have two issues with AntlrWorks.
>    * When I check grammar, I get a popup that says "Check 
> Grammar Succeeded" gut the console says "Aborting because the 
> following rules are mutually left recursive. [funcCall]"
>    * When I try the "Refactor" method to eliminate left 
> recursion, it tells me that the method doesn't have left 
> recursion.
>
>grammar boo;
>
>funcCall
>             :           (IDENT | funcCall) list;
>list:       '(' IDENT ')';
>
>IDENT
>             :           'XXX';

ANTLRworks currently doesn't seem to identify recursion where 
there are parentheses involved.  If you expand the brackets 
(similar to how you'd do it in algebra) then you can get it into a 
state where ANTLRworks can sort it out.  ie. the first step is to 
change it to this:

funcCall:  IDENT list | funcCall list;

ANTLRworks' recursion eliminator should then work on it, and 
you'll end up with this (in b9, at least):

funcCall:  (IDENT list) (list)*;

Although now that I look at that, it seems incorrect.  "funcCall 
list" is basically "list+", so the real replacement rule would be:

funcCall: IDENT list | list+;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070509/dfab8d54/attachment.html 


More information about the antlr-interest mailing list