[antlr-interest] [SPAM] [SPAM] non-LL(*) error with nested arrays

John B. Brodie jbb at acm.org
Thu Jun 24 18:44:53 PDT 2010


Greetings!

On Fri, 2010-06-25 at 03:00 +0200, Olivier Lefevre wrote:
> Greetings ANTLR experts,
> 
> I have the attached toy grammar for integer arrays of arbitrary
> depth but the stat rule has non-LL(*) decision due to recursive
> rule invocation. It is recommended to left-factor or to use a
> syntactic predicate; in principle I know what both are (I just
> reread the applicable sections in the book) but it's been a while
> since I last used ANTLR and in this case, with the added twist of
> recursion, I still don't get it. Can someone offer a hint?

according to your rules, a stat may be either an array or an expr and an
expr may be either an INT or an array. e.g.:

stat : array | expr ;
expr : INT | array ;

remove the array from the stat rule because the expr rule gets us that
syntax already.

hope this helps...
   -jbb




More information about the antlr-interest mailing list