This antlr example is not working properly
Posted
by Aftershock
on Stack Overflow
See other posts from Stack Overflow
or by Aftershock
Published on 2010-05-01T18:40:47Z
Indexed on
2010/05/01
18:47 UTC
Read the original article
Hit count: 727
Hi,
This ANTLR example does not parse input "1;" . Can you explain why? It parses "11;".
grammar test;
options
{//language = 'CSharp2';
//language = 'Java';
output=AST;
}
expr : mexpr (PLUS^ mexpr)* SEMI!
;
mexpr
: atom (STAR^ atom)*
;
atom: INT
;
//class csharpTestLexer extends Lexer;
WS : (' '
| '\t'
| '\n'
| '\r')
{ $channel = HIDDEN; }
;
LPAREN: '('
;
RPAREN: ')'
;
STAR: '*'
;
PLUS: '+'
;
SEMI: ';'
;
protected
DIGIT
: '0'..'9'
;
INT : (DIGIT)+
;
© Stack Overflow or respective owner