[antlr-interest] non-determinism warnings again

John B. Brodie jbb at acm.org
Fri Jul 8 08:44:54 PDT 2005


Tarun Khanna asked (in part):

>Hi All,

Greetings!

>I am getting a non-determinism warning between alt 1 and the exit branch.
>
>k=3D1 DOT and k=3D2 IDENT.
>I have a look-ahead of 2.

...snip...

...apparently this is the rule causing the problem...

>F
>:=20
>NUM
>|
>(LPAREN e=3Dexp RPAREN) (DOT IDENT)* (DOT TAB)?
>|
>IDENT (DOT IDENT)* (DOT TAB)?
>|
>TAB
>;
...(is this in the Lexer? no, can't be, refers to a parser rule, exp)...

Perhaps I misunderstand your question.  I tried this small grammar:

//begin test.g
class testParser extends Parser;

options { k = 2; }

f :
        NUM
    | (LPAREN exp RPAREN) (DOT IDENT)* (DOT TAB)?
    | IDENT (DOT IDENT)* (DOT TAB)?
    | TAB
;

exp : FOO ;
//end test.g

and received no complaints at all.

is it possible that there is some interaction amongst your rules?

maybe you could post the smallest complete grammar that displays the
ambiguity and then we could try to fix that...

Hope this helps...
   -jbb



More information about the antlr-interest mailing list