[antlr-interest] Escaping single quotes in a lexer

Gavin Lambert antlr at mirality.co.nz
Fri Mar 27 13:04:26 PDT 2009


At 05:25 28/03/2009, Emanuele Gesuato wrote:
 >DELIM : "\'' ('\\' ('\'')? | ~('\\' | '\''))* '\'";
 >
 >As described below i'm using antlr 2.7.6. I've tried to use it
 >as a delimiter to my string using:
 >
 >STRING : DELIM((JOLLY)?(PAROLE|INTEGER)(JOLLY)?)DELIM;

The rule I posted is not a delimiter rule; it is a rule for 
matching the entire STRING.

In v2 syntax it'd be:

STRING : "'" ("\\" ("'")? | ~("\\" | "'"))* "'";

(I don't quite remember if you need to double the backslashes in 
v2, but I think you do.)



More information about the antlr-interest mailing list