non-determinism errors... pls help
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sun_set
Posted On:   Thursday, January 31, 2002 07:25 PM

I have a subset of rules that I have to convert to ANTLR compatible format: expression : expression '+' term | expression '-' term | term; term : term '*' factor | factor; factor : VAR | INT | '(' expression ')'; I tried to fix the infinite recursion errors by changing to: expression : ( term | term ('+' term)+ | term ('-' term)+ ); term :( factor | factor ('*' factor)+ ); factor : ( VAR | constant | '(' expression ')' ); now I got these errors warning: nondeterminism upon k==1:VAR,INT,LPAREN between alts 1 and 2 of block warning: nondeterminism upon k==1   More>>

I have a subset of rules that I have to convert to ANTLR compatible format:



			
expression : expression '+' term | expression '-' term | term;
term : term '*' factor | factor;
factor : VAR | INT | '(' expression ')';



I tried to fix the infinite recursion errors by changing to:



			
expression : ( term | term ('+' term)+ | term ('-' term)+ );
term :( factor | factor ('*' factor)+ );
factor : ( VAR | constant | '(' expression ')' );



now I got these errors



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

warning: nondeterminism upon
k==1:VAR,INT,LPAREN
between alts 1 and 3 of block

warning: nondeterminism upon
k==1:VAR,INT,LPAREN
between alts 2 and 3 of block

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

warning: nondeterminism upon
k==1:"call","while","if","assign"
between alts 1 and 2 of block




Please help. Thanks!


   <<Less

Re: non-determinism errors... pls help

Posted By:   Terence_Parr  
Posted On:   Saturday, February 2, 2002 09:53 AM

I would look at the java grammar or the simple calculator examples. Your problem is very common and is correctly written up in the various examples.
About | Sitemap | Contact