[antlr-interest] non-determinism... please help...

Bryan Ewbank ewbank at gmail.com
Sun Apr 17 14:44:04 PDT 2005


Looking just at /prefix1/, the second and fourth alternatives need to
be collapsed - they are currently ambiguous - so that ANTLR can digest
them:

  prefix1 : '[' exp ']' 
            : '.' ID ( args )?
            : args 
            ; 

Once this is cleared, there are also problems in the interactions
between /var/ and /prefix1/...

Consider the input "ID[exp]"...  When the "[" is encountered; is it
the "[" in prefix1, or is it the "[" is the original var definition
(and collapse prefix1 to null).

Likewise for the input "ID . ID"... the ". ID" can be either a
prefix1, or the variable match.

Hope this helps,
- Bryan

> var : ID 
>      | prefix ( ( '[' exp ']' ) | ( '.' ID ) ) 
>      ; 
>   
> prefix : ( ID | ( '(' exp ')' ) ) (prefix1)*;
>
> prefix1 : '[' exp ']' 
>           : '.' ID 
>           : args 
>           : ':' ID args 
>           ;


More information about the antlr-interest mailing list