[antlr-interest] ANTLR v3.0.1: Regression from ANTLR v2:?? left recusrsive grammar detected while it's not.
Johannes Luber
jaluber at gmx.de
Mon Aug 11 14:37:45 PDT 2008
Francis ANDRE schrieb:
> >>You have three section-s here - one for the rule, one for return and
> one as label. ANTLR gets confused there. Rename at least the label and
> the return parameter.
> Yes, I know.. it was done on purpose and works fine in ANTLR v2.. And as
> the grammar has a more than 300 rules and 600 tokens, I would prefer to
> let them as is
> Since ANTLR knows perfectly this is an assignment from a returned value
> to a target language variable, IMHO, "section = " could be corrected as
> a reference to the section variable and not an invocation of the
> 'section' rule.
The "Since ANTLR knows perfectly this is an assignment from a returned
value to a target language variable" part can be debated, but I don't
know if a label can point to a return value anyway. Also I don't think
it is a good idea to allow the redefinition of names - people can be
easily confused.
Johannes
> Cheers
>
> FA
>
> Johannes Luber a écrit :
>>
>> Francis ANDRE schrieb:
>>> Hi ANTLR's
>>>
>>> Upon migration from ANTLR v2 to ANTLR v3 on the following snippet
>>>
>>> grammar Cobol;
>>> tokens { DOT='DOT'; SECTION='SECTION'; IDENT='IDENT';}
>>> debut : section;
>>>
>>> section returns[PROCEDURE_SECTION section = null]
>>> @init {String s;} : section = sectionHeader DOT ;
>>
>> You have three section-s here - one for the rule, one for return and
>> one as label. ANTLR gets confused there. Rename at least the label and
>> the return parameter.
>>
>> Johannes
>>>
>>> sectionHeader returns[PROCEDURE_SECTION section = null]
>>> : IDENT SECTION { section = $IDENT.getText(); };
>>>
>>>
>>> got this error: [17:39:46] error(211): Cobol.g:2941:6: [fatal] rule
>>> section has non-LL(*) decision due to recursive rule invocations
>>> reachable from alts 1,2. Resolve by left-factoring or using
>>> syntactic predicates or using backtrack=true option.
>>>
>>> IMHO, in no way the 'section = ' is a left recursive invocation of
>>> the section rule, but just the assignment if the result of
>>> sectionHeader to the PROCEDURE_SECTION section.
>>>
>>> What's yours?
>>>
>>> FA
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
More information about the antlr-interest
mailing list