[antlr-interest] expression parser example Expr.g dont work
Mats Ekberg
mats.ekberg at arcticgroup.se
Tue Jan 6 22:21:55 PST 2009
I have stripped the classical expr.g example and when I run it in
ANTLRWorks it dont work.
The input "(1 + 2) * 3 - 4" (with a newline at the end) just recognizes
"( 1 + 2" and the nothing more.
How come?
grammar Expr;
prog: stat+ ;
stat: expr NEWLINE
| NEWLINE
;
expr
: multExpr ( '+' multExpr | '-' multExpr )*
;
multExpr
: atom ('*' atom )*
;
atom
: INT
| '(' expr ')'
;
INT : '0'..'9'+ ;
NEWLINE:'\r'? '\n' ;
WS : (' '|'\t')+ {skip();} ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090107/64dd4655/attachment.html
More information about the antlr-interest
mailing list