[antlr-interest] Lexer rule with alternatives (Newbie question)
Петров Александр
gmdidro at gmail.com
Sat Nov 22 07:49:16 PST 2008
Hello,
why such grammar doesn't work properly:
--------------------------------------------------------------------------------------
expr :
operand ((oper) operand)*
;
//Correct operands
operand :
INT
;
OPER: ('+'|'-'|'*'|'/')
;
INT :
('0'..'9')+
;
--------------------------------------------------------------------------------------
> t+1
line 0:3 mismatched input '+' expecting EOF
But if I replace the Lexer rule by Parser rule:
oper: ('+'|'-'|'*'|'/');
All work as it should. Why I should't use Lexer rule with alternatives ?
Thank you
More information about the antlr-interest
mailing list