[antlr-interest] newbie left-recursive problem

Frank Smith fasmith718 at gmail.com
Thu Jul 5 07:50:02 PDT 2007


The problem is that everything that you call off of the expression rule
(such as infixexpression) begins with a call to the expression rule again.

The wikipedia entry for fixing left recursion seems to follow the formula
from The Dragon Book (by Al Aho, et al)  and that worked for me in my
grammar:
http://en.wikipedia.org/wiki/Left_recursion

Good luck.

On 7/5/07, ali azimi <aliaazimi at yahoo.com> wrote:
>
> Hi,
>
> I have read some articles about left-recursive problem and managed to
> understand the nature of the problem. However I can not remedy the problem I
> am facing in my grammar. I am hoping you can help me.
>
> You can see left-recursive problems in the followings. how can I remedy
> them?
> variable:fieldmodify|elementmodify|variableidentifier
>  ;
> elementmodify
>  :variable'('expression(','expression)*')'
>  ;
> fieldmodify
>  :variable'!'fieldname
>  ;
> expression
>
>  :literalidentifier|synonymidentifier|variableidentifier|fieldextract|elementextract|infixexpression|parenthesisexpression
>
>  |operatorapplication|valuemake|imperativeoperator|conditionalexpression|forallname|spellingexpression
>  ;
>
> and the followings:
>
> infixexpression
>  :expression dyadicoperator expression
>  |monadicoperator expression
>  ;
> elementextract
>  :expression '('expression (',' expression)*')'
>  ;
> fieldextract
>  :expression '!'fieldname
>  ;
>
>
> Thank you so much in advance,
> Al
>
> ------------------------------
> Get the free Yahoo! toolbar<http://us.rd.yahoo.com/evt=48226/*http://new.toolbar.yahoo.com/toolbar/features/norton/index.php>and rest assured with the added security of spyware protection.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070705/5275997d/attachment-0001.html 


More information about the antlr-interest mailing list