[antlr-interest] nondeterminism question

Klaas Hofstra antlr at klaashofstra.com
Thu Sep 1 06:43:10 PDT 2005


Hi,

I encountered a nondeterminism warning but when I look at my grammar I don't 
see the reason.

When I check the generated code I see exactly what I expect. However, I must 
be missing something because I get this warning:

warning:nondeterminism between alts 1 and 2 of block upon
     k==1:LPAREN

The warning point to the "integer" line in this rule:

typeDef
    : "signed"
    | "unsigned"
    | "float"
    | ("integer" ( LPAREN! range RPAREN! )? )      <= warning on this line
    ;

Selected parts of the rest of the grammar are shown below:

-----------------------------------

range 
    : expression DOTDOT! expression
    ;

expression
/* 
 standard (C like) expression grammar with an added bitIndex and 
 bitSlice operator as shown below
*/


postFixExpression
    : (primaryExpression | (LPAREN! expression RPAREN!)) (
      (bitIndexExpression) => bitIndexExpression
    | bitSliceExpression 
    | arrayIndexExpression
     )?
    ;

arrayIndexExpression
    : LBRACKET! logicalExpression RBRACKET!
    ;

bitIndexExpression
    : LPAREN! logicalExpression RPAREN!
    ;

bitSliceExpression
    : LPAREN! logicalExpression DOTDOT! logicalExpression RPAREN!
    ;


-----------------------------------

I hope someone can explain to me why I get this warning so I can fix my 
grammar.

Thanks in advance,

Klaas


More information about the antlr-interest mailing list