[antlr-interest] lexing expression ('a'..'z')+ not matching single character input

Gavin Lambert antlr at mirality.co.nz
Wed Dec 13 01:05:34 PST 2006

At 06:10 13/12/2006, Matt Harrison wrote:
 >I am having trouble diagnosing why the (common) lexer expression 

 >"('a'..'z')+" is not matching any single character input (eg: 
 >in my grammar. Is there any situations under which this 
 >should not match a single character in the range 'a' - 'z'?

I don't have the answer to your question, but I did notice:

 >        : ( '\r' '\n' )
 >        | '\n'                                  {   newline();
 >$setType( Token.SKIP );  }
 >        ;

I'm fairly sure that this is wrong.  The action will be applied 
only to the second alt, meaning that when seeing '\r\n' in the 
stream it won't skip it.  You should add an extra set of 
parentheses around both alts, so you've only got a single unit 
before the action.

More information about the antlr-interest mailing list