[antlr-interest] MismatchedTokenException

Marcin Rzeźnicki marcin.rzeznicki at gmail.com
Wed Dec 16 10:44:31 PST 2009

2009/12/14 Marcin Rzeźnicki <marcin.rzeznicki at gmail.com>:
> 2009/12/13 Jim Idle <jimi at temporal-wave.com>:
>> This usually means that your lexer token numbers are out of sync with your
>> parser tokens. Regen in correct order and make sure all tokens have been
>> declared.
> Umm, what if I work with combined grammar? And some of literals are 'inlined'?

I think I know what has been causing this problem but I am scratching
my head. It seems that ANTLR lexer is, well, a strange beast.
I have a rule, say

and below

  {Character.isJavaIdentifierStart(input.LA(1))}?=> . (
{Character.isJavaIdentifierPart(input.LA(1))}?=> . )*

(the latter rule has been questioned here, but bear with me a while, I
need it to explain my case)

Now, upon seeing input 'class' ANTLR matches IDENTIFIER because of
this gating predicate. Well, 'class' would have been a valid
identifier, of course but shouldn't it try to match 'class' based on
rules precedence?
Marcin Rzeźnicki

More information about the antlr-interest mailing list