[antlr-interest] pls look at my parser, who can help me to kill this nest problem!

ib_icf ib_icf at yahoo.com.cn
Tue Sep 14 03:17:45 PDT 2004


I found this toy very interesting, but meet some problems, here is 
the definition of my parser:

class ExprParser extends Parser;
stat 
	: expr
	| ifStat 
	;
ifStat 
  	: IF ifPart END IF 
  	;
ifPart 
  	: expr THEN stat 
    	  ( ELSE stat )?
  	;
expr 
	: andExpr 
	    (AND andExpr 
	    |OR  andExpr
	    )*
	;  
andExpr 
	: numExpr 
	    (EQUAL numExpr  
	    |GREAT numExpr 
	    |LESS  numExpr  
	    |GRTEQ numExpr  
	    |LESEQ numExpr  
	    )?
	| LPAREN expr RPAREN
	;
numExpr 
	: mexpr
	( PLUS mexpr  
	| MINUS mexpr 
	)*
	;
mexpr 
	: atom 
	( STAR atom 
	| DIV atom 
	)*
	;
atom 
	: i:NUM 
	| LPAREN numExpr RPAREN
	;

=====================================================
end of defintion
=====================================================
Because I use bracket for atom, I meet a problem when I want to add 
another bracket for the andExpr, well, what can I do?

when i compile it, the error message is:
ANTLR Parser Generator   Version 2.7.3   1989-2004 jGuru.com
tz.g:19: warning:nondeterminism between alts 1 and 2 of block upon
tz.g:19:     k==1:LPAREN

Appreciate it!

Tiger




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list