[antlr-interest] Parser Error:Expecting ID
Grzegorz Bugaj
gregbugaj at yahoo.com
Mon Mar 7 11:38:54 PST 2005
Hi, This is my first attempt to play with antlr so any comments are welcome. here is the error that I am reciving: line 1:5: Expecting ID found 'greg'
here is my input file:
int greg=3;
int leo=4;
and here is my grammar file.
class ExprLexer extends Lexer;
options
{
exportVocab=V;
charVocabulary = '\3'..'\377' | '\u1000'..'\u1fff';
caseSensitive=false;
}
VARINT :"int";
PRINT :"print";
STATUS :"status";
IDENTIFIER :(UNDERSCORE|DOLLAR)? (LETTER|DIGIT)+;
NUMBER :(DIGIT)+ ('.' (DIGIT)+ )?;
LETTER :('a'..'z');
LEFTPAREN :'(';
RIGHTPAREN:')';
UNDERSCORE:'_';
DOLLAR:'$';
DIGIT :('0'..'9');
INTO:'*';
DIV:'/';
PLUS:'+';
MINUS:'-';
ISEQUALTO:'=';
SEMI: ';';
// whitespace
WS:
( ' '
| '\t'
| ( "\r\n" | '\r' | '\n' )
{ newline (); }
)
{ $setType(Token.SKIP); }
;
ID : LETTER (LETTER | DIGIT)*;
// ----------------------------------------------------------------------------
class ExprParser extends Parser;
options
{
k = 2;
buildAST = true;
importVocab=V;
}
print:PRINT;
setinteger: VARINT ID ISEQUALTO
{System.out.println("Integer Var");}
;
Any sugestions ?
Regards
Greg Bugaj
---------------------------------
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050307/e8645757/attachment-0001.html
More information about the antlr-interest
mailing list