There are two problems with the above rules.
- You didn't actually escape your quote like you thought. You meant to use
'\\"'
. - Your
ESCAPED_QUOTE
rule doesn't form a token all by itself, so it should be afragment
rule.
The result of these two changes would be the following:
fragment ESCAPED_QUOTE : '\\"';
QUOTED_STRING : '"' ( ESCAPED_QUOTE | ~('\n'|'\r') )*? '"';