[antlr-interest] Fighting nondeterminism

rustydstone rustydstone at yahoo.com
Mon Apr 28 12:55:40 PDT 2003


Hi,

The following is somewhat simplified version of java.g

I think that there is a conflict between additiveExpression and
unaryExpression, i.e. if I remove PLUS and MINUS from unaryExpression
it will work but that's not exactly what i want.

Any ideas on how it could be fixed the "right" way? Thanks

---------------------------------------------------------
...
// binary addition/subtraction (level 3)
// the following line is line # [258], see errors below
additiveExpression
: multiplicativeExpression ((PLUS^ | MINUS^) multiplicativeExpression)*
	;

// multiplication/division/modulo (level 2)
multiplicativeExpression
        : unaryExpression ((STAR^ | DIV^ | MOD^ ) unaryExpression)*
	;

unaryExpression
	: MINUS^ {#MINUS.setType(UNARY_MINUS);} unaryExpression
	| PLUS^  {#PLUS.setType(UNARY_PLUS);} unaryExpression
	| unaryExpressionNotPlusMinus
	;

unaryExpressionNotPlusMinus
	: LNOT^ unaryExpression
	| primaryExpression
	;
...
ANTLR Parser Generator   Version 2.7.2   1989-2003 jGuru.com
com/test/test.g [258] warning:nondeterminism upon
com/test/test.g [258] k==1:MINUS,PLUS
com/test/test.g [258]
k==2:BOOLEAN,NULL,LNOT,MINUS,NUM_INT,PLUS,STRING_LITERAL,NUM_FLOAT
com/test/test.g [258] between alt 1 and exit branch of block



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list