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

Ludwig Maes ludwig.maes at gmail.com
Sat Apr 7 14:56:17 PDT 2012


Well, I still fail to find the recursion cycle, so maybe you are
right, perhaps the wrong error message is displayed? either way if a
(mutual) left recursion is found (a cycle was detected by antlr) why
cant it print out the cycle sequence?

On 7 April 2012 23:06, John B. Brodie <jbb at acm.org> wrote:
> 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