[antlr-interest] stuck expr

mzukowski at yci.com mzukowski at yci.com
Wed Oct 1 06:28:04 PDT 2003


Perhaps you are never sending EOF.  Is the input a file or from the command
line?  Try it from a file.

Monty

-----Original Message-----
From: jagad [mailto:jagad at enciety.com] 
Sent: Wednesday, October 01, 2003 6:32 AM
To: ANTLR Milis
Subject: [antlr-interest] stuck expr

Hi All,

I have simple parser like this one;

//***** Parser *****
class MyParser extends Parser;

goal       : exprList SEMI EOF;

exprList   : expr (COMMA expr);

expr       : simpleExpr (relOp simpleExpr)*;

simpleExpr : (PLUS | MINUS)? term (addOp term)*;

term       : factor (mulOp factor)*;

factor     : NUM_INT
           | NUM_REAL
           | (LPAREN expr RPAREN)
           ;

mulOp      : STAR | SLASH | DIV | AND | SHL| SHR;
addOp      : PLUS | MINUS | OR | XOR;
relOp      : GREATHAN 
           | LESSTHAN | GREATHANEQU | LESSTHANEQU |EQU|NOTEQU;

//********************

The I gerenate into C++ code, the problem is the parser allways stuck on
expr and never reach the goal. I have try to set options{ k=xx} with no
effect.

For input:

(1+2);

the output is:

NUM_INT      <----- factor: NUM_INT
term         <----- term: factor 
PLUS         <----- addOp: PLUS 
NUM_INT      <----- factor: NUM_INT 
term         <----- term: factor 
simpleExpr   <----- simpleExpr: term (addOp term)*; 
expr         <----- expr: simpleExpr
( expr )     <----- factor: (LPAREN expr RPAREN)
term         <----- term: factor
simpleExpr   <----- simpleExpr: term
expr         <----- expr: simpleExpr

Why my parser never reach goal? please, let me know.

Thanks in Advance and Best Regards

jagad




 

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


 

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




More information about the antlr-interest mailing list