[antlr-interest] beginner's question
Yuxiao Hu
huyuxiao at gmail.com
Tue May 24 08:30:05 PDT 2005
Hi all,
I am learning ANTLR, and tried pasting the sample program in the
editor, but antlr gives the following error message:
ANTLR Parser Generator Version 2.7.5 (20050426) 1989-2005 jGuru.com
TokenStreamException: expecting '(', found ' '
however, it does not tell me in which line this error is.
who can tell me where the problem is?
thanks
program:
class CalcParser extends Parser;
options {
buildAST = true;
}
expr : mexpr (PLUS^ mexpr)* SEMI!
;
mexpr : atom (STAR^ atom)*
;
atom : INT
;
class CalcLexer extends Lexer;
WS : (' '
| '\t'
| '\n'
| '\r')
{ _ttype = Token.SKIP; }
;
LPAREN : '('
;
RPAREN : ')'
;
STAR : '*'
;
PLUS : '+'
;
SEMI : ';'
;
INT : ('0'..'9')+
;
class CalcTreeWalker extends TreeParser;
expr : # (PLUS expr expr)
| # (STAR expr expr)
| INT
;
More information about the antlr-interest
mailing list