[antlr-interest] C++ grammar, troubleshooting mutually left recursive rules

John B. Brodie jbb at acm.org
Sat Apr 7 14:06:53 PDT 2012


Sorry!

On 04/06/2012 04:10 PM, Ludwig Maes wrote:
> Hello, thanks for helping me out
>
> My misunderstanding was that I thought recursion meant (in)directly
> calling itself (of which I could not find a cycle). If I understand
> correctly, you point out that "mutually left-recursive" actually means
> that the call trees of the 3 functions intersect. Why is that not
> allowed? it would seem to imply every rule may only be usaged in just
> one other rule?

Sorry for my error.

You are correct. Mutual left recursion is a (possibly indirect) cycle.

For some reason I mis-read your question and was responding to removing 
ambiguity by finding common left prefixes. Which was not your question 
and may not be a problem with these particular rules.

>
> I.e. : if I define a rule called digit, I can use/call this rule in
> other rules. Why would that be allowed but not what we have here be
> allowed?
>
> Perhaps there is a real recursion but when I draw the directed graph
> of calls in the steps you mention I get an acyclic graph...
>
> I must be misunderstanding something
>
>

Sorry for the noise.
    -jbb



More information about the antlr-interest mailing list