[antlr-interest] MismatchedSetException in lexer grammar

Tyler Distad tyler.distad at gmail.com
Wed Apr 14 04:51:30 PDT 2010


I have the following grammar:

fragment TAB : '\t';
fragment PRINTABLE : '\u0020'..'\u007F' | TAB;

fragment DELIM: '|||||';
FILE_DELIMITER : DELIM (PRINTABLE ~ '|')+ DELIM;

I have the following sample lexer rules:
|||||12|||||
|||||123|||||

The ANTLR interpreter accepts the first one, but the generated tree diagram
looks like:
FILE_DELIMITER:
 |--DELIM
 |--PRINTABLE
 |--DELIM
(Note there's only one PRINTABLE.)

For the second one, the ANTLR interpreter blows up with a
MismatchedSetException and a diagram like:
FILE_DELIMITER:
  |--DELIM
  |--PRINTABLE
  |--PRINTABLE
  |--MismatchedSetException

This pattern is reproducible: any input with an even number of PRINTABLE
characters succeeds. All odd inputs fail.

Any thoughts?

Tyler Distad


More information about the antlr-interest mailing list