[antlr-interest] Weird parser bug with character ranges

Ian Beveridge ian.beveridge at gmail.com
Mon Sep 3 07:13:06 PDT 2007


I've got a parser working in antlr 3.0.1 and everything is great
except for one bizarre problem. I have this to define an identifier...

IDENT
   : ('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
   ;

which seems straight-forward enough. The weird thing is that all of
these things work fine...

 myvar = 1
 myvar2 = 1
 aa = 1
 b = 1

but this fails...

 a = 1

with

line 15:8 required (...)+ loop did not match anything at input 'a'

I'm puzzled as to why 'a' should fail but not 'b'. My grammar is
obviously much longer than that one line so I guess it's possible that
it could be a problem elsewhere in my file but it seems like such a
strange problem.

Any clues?

- Ian Beveridge


More information about the antlr-interest mailing list