[antlr-interest] MismatchedTokenException and how to find errors in ANTLRWorks

Micke Hovmöller micke.hovmoller at gmail.com
Tue Feb 12 10:05:52 PST 2008


I have a bit of a problem finding the errors in my grammar, and would
appreciate some hints on how to go about finding them.

I have this rule in my grammar:
dealingriver
	:	'** Dealing River ** :  [ ' CARD ']' NEWLINE ;

and this input:
** Dealing River ** :  [ 3d ]

(All this part of larger grammar and input.)

ANTLRWorks finds the dealingriver rule, splits it into '** Dealing
River ** :  [ ' and 3d but gives this message as the third leaf in the
node:
  MismatchedTokenException(5!=31)

This leads to my questions:
1. Is there a more extensive list of error messages than the fairly
short one in the ANTLR reference book?

2. What is the easiest way to find which tokens are referred to by, in
this case, 5 and 31? If I generate the grammer, I can look in the
.token file, but that seems tedious. Can't I find that inside
ANTLRWorks somewhere? (FWIW, this is what I found in the .token file:
'** Dealing Turn ** :  ['=31
ID=5

ID is defined as:
ID: ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'_'|'0'..'9')+ ; )


3. I get this error a lot, it seems. How should I think/what should I
look for in debugging?

(4. Is it obvious what is wrong here? I expect to have found the issue
shortly, but I'm still interested in the general questions above.)

/Micke


More information about the antlr-interest mailing list