[antlr-interest] nondeterminism question
shmuel siegel
antlr at shmuelhome.mine.nu
Thu Sep 1 06:57:20 PDT 2005
Klaas Hofstra wrote:
>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
>
>
>
I am guessing at the structure of expression but it seems to me that
range, and therefore the line in question, can't distinguish between a
grouped expression and a bitSpliceExpression. Does changing k, the
lookahead, value help.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/86 - Release Date: 8/31/2005
More information about the antlr-interest
mailing list