[antlr-interest] Escaping quotes in a lexer
Emanuele Gesuato
emanuele.gesuato at gmail.com
Wed Mar 25 02:04:47 PDT 2009
I'm sorry i haven't understad how could i use your code snippet.
I've tried to prefix/append your snippet to my code but antlr refuses
to compile.
I'm very new to antlr :)
Thanks for any help,
Emanuele
Gavin Lambert wrote:
> At 05:56 18/03/2009, Gesuato Emanuele wrote:
>> I would like to use the ' character inside the string something
>> similar to:
>>
>> Invoice.customer='Tom L\'oreal'
>> or (better)
>> Invoice.customer="Tom L'oreal"
>>
>> I've got the String definition for such fields that is the following:
>> STRING : "'"((JOLLY)?(PAROLE|INTEGER)(JOLLY)?)"'";
>
> Are you sure that *s can only appear at either end, never in the middle?
>
> Anyway, if you want to permit a \' escape, then you have to explicitly
> spell it out. Personally, though, I wouldn't try to be even slightly
> restrictive on the contents of the string -- leave that to later
> validation in the parser or external code:
>
> STRING : '\'' ('\\' ('\'')? | ~('\\' | '\''))* '\'';
>
More information about the antlr-interest
mailing list