[antlr-interest] a question about AST tree

xdm xdm at suzsoft.com
Sat Dec 30 23:44:24 PST 2006


It is a simple expression. 

 

class CalcParser extends Parser;

options { buildAST=true; }

expr : ( NUM expr_tail  )  | ( LPAREN!  expr RPAREN!  expr_tail ) ;

expr_tail : ( (PLUS^|SUB^|MUL^|DIV^) expr )*  ;

 

 

For the expression "2+4", the result is supposed to be "+ 2 4", but I just
get "2". 

 

Can you tell me why??

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20061231/7e3da08f/attachment.html 


More information about the antlr-interest mailing list