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();} ;

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to