[antlr-interest] Lexer rule for single quote

John Connett jrc at skylon.demon.co.uk
Tue Jul 24 14:42:55 PDT 2007


On Tue, 2007-07-24 at 21:55 +0100, John Connett wrote:
> On Tue, 2007-07-24 at 10:40 -0700, Sam Edwards wrote:
> > In ANTLR v 3, single quotes are used for character literals.  I have
> > my entire lexer working correctly except for the TIC.  I have the
> > rule:
> >  
> > TIC    :'\''; which never gets discovered.  What I'm trying to
> > recognize is a single TIC (apostrophe).
> > 
> > Is my lexer rule written correctly, or do I need a different escape
> > character?
> > 
> > Thank you,
> > -Sam
> 
> On a related note I was attempting to use the following lexer rule to
> recognize a string of one or more printable ASCII characters excluding 
> SPACE, EQUALS and PIPE:
> 
> STRING  : ('!'..'<' | '>' .. '{' | '}'..'~')+ ;
> 
> However, strings containing QUOTE characters are not recognized as a
> single token.  I have lloked in the FAQ but have not found a work
> around.
> --
> John Connett

Oops!  I need my eyes tested.  What at first glance appeared to be
single quotes where actually three byte sequences representing something
like left and right single quote characters.  Rather fancy for a
compiler warning message ...

Sorry
--
John Connett



More information about the antlr-interest mailing list