[antlr-interest] Lexer rule for single quote
John Connett
jrc at skylon.demon.co.uk
Tue Jul 24 13:55:38 PDT 2007
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
More information about the antlr-interest
mailing list