[antlr-interest] error(211)

John B. Brodie jbb at acm.org
Mon Aug 6 06:58:21 PDT 2007


on Mon, 6 Aug 2007 10:39:43 +0200, Martin Kohl asked:
>I've stumbled upon an error:
>error(211): Expr.g:490:3: [fatal] rule rule_name has non-LL(*) decision due
>to recursive rule invocations reachable from alts 1,4.  Resolve by
>left-factoring or using syntactic predicates or using backtrack=true option.
>
>I've had this error in a few other places and I resolved it by setting the
>backtrack=true option. However this doesn't work for this rule:
>        (    expression ','
>        |    '*' ','
>        |    ','
>        )*
>        expression ':'
>
>The Line Reference of the error message points to the second expression. If
>I remove the * or the second expression the error is resolved.

It is hard to be really definitive without seeing your entire grammar.
But you might try left-factoring (un-tested):

rule_near_line_490
    : (('*' | ',') expression_tail )
    | expression ( ':'
                 | expression_tail )
    ;

expression_tail
    : ',' ( ( '*'? expression_tail )
          | ( expression ( ':'
                         | expression_tail) )
          )
    ;




   -jbb


More information about the antlr-interest mailing list