[antlr-interest] trouble running Antlr on grammar file
Kumar, Rajesh (Systems) UTRC
KumarR at utrc.utc.com
Tue Apr 20 10:51:32 PDT 2010
Hi everyone,
I created a simple expression grammar in a .g file. I checked it with Antlrworks to see that there were no errors in the grammar. The grammar is the following:
****************
grammar Expression;
prog : exp
;
exp : '(' exp ')' exp_t
| atomic_expr exp_t
| '!' atomic_expr exp_t
;
exp_t : '->' exp exp_t
| '&&' exp exp_t
| '||' exp exp_t
|
;
atomic_expr
: ID
| 'Unavailable' '(' GEN ')'
| 'Powers' '(' GEN ',' ID ')'
| 'OnlyAvailable' '(' GEN ')'
;
ID : ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9')*
;
NUM : ('0'..'9')+
;
GEN : 'X_L1'
| 'X_L2'
| 'X_R1'
;
WS : (' '|'\t')+ {skip();};
********************
When I run "java antlr.Tool Expression.g" I get the following
ANTLR Parser Generator Version 2.7.7 (20060906) 1989-2005
Expression.g:1:1: unexpected token: grammar
error: Token stream error reading grammar(s):
Expression.g:11:13: expecting ''', found '>'
Expression.g:1:1: rule grammar trapped:
Expression.g:1:1: unexpected token: grammar
TokenStreamException: expecting ''', found '>'
Can anyone help me out?
Thanks.
Rajesh
More information about the antlr-interest
mailing list