[antlr-interest] Simple grammar with error
Alfonso
barbolani at ya.com
Sat Sep 15 02:11:19 PDT 2007
I'm using ANTLRWorks to learn the basics of ANTLR. Can someone explain
me why this grammar
grammar Failed;
expression
: term ( (PLUS|MINUS) expression)?
EOF
;
term :
atom ( (DIVIDE | ASTERISK) term)?
;
atom :
NUMBER
| OPEN_PAREN expression CLOSE_PAREN
;
NUMBER : '0'..'9' ('0'..'9')*;
PLUS : '+';
MINUS : '-';
DIVIDE : '/';
ASTERISK : '*';
OPEN_PAREN : '(' ;
CLOSE_PAREN: ')' ;
Generates a "NoViableAltException" after the "5" when facing the
expression 2*(3+5)+1 in the interpreter?
Surely this is a basic question, but for god's sake I'm not able to
understand it.
Thanks in advance
More information about the antlr-interest
mailing list