[antlr-interest] Integer literal ending problem

Shevchenko A ashe at 1c.ru
Tue Dec 13 03:46:09 PST 2011


I am trying to write some tests for the lexical parser generated with ANTLR.
My grammar is simple:
INT: ('0'..'9')+;
ID: ('A'..'Z') ('A'..'Z' | '0'..'9')* ;
WS: (' ' | '\r' | '\n')* { skip(); };

With such a grammar the parser will interpret the string "123A" as 2 tokens,
and this is undesirable.
If I specify that integer should be ended with whitespace another problem
will come up. Not only whitespace is the ending but also all special

So, the question is about best practices to solve the problem.
Thanks in advance.

Anton Shevchenko,
1C Company, Moscow.

More information about the antlr-interest mailing list