[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 13:59:48 PDT 2008
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