[antlr-interest] newbie question - string literals

Gavin Lambert antlr at mirality.co.nz
Thu Dec 10 00:08:23 PST 2009


At 14:04 10/12/2009, Duygu Altinok wrote:
>STR
>     :   '`' ( ESC_SEQ | ~('\\'|'"') )* '\'';

That double-quote should be a single quote.

>ESC_SEQ
>     :   '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\')
>     |   UNICODE_ESC
>     |   OCTAL_ESC
>     ;
>
>OCTAL_ESC
>     :   '\\' ('0'..'3') ('0'..'7') ('0'..'7')
>     |   '\\' ('0'..'7') ('0'..'7')
>     |   '\\' ('0'..'7')
>     ;
>
>UNICODE_ESC
>     :   '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
>   ;
>
>HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;

All of these should be marked as fragments.



More information about the antlr-interest mailing list