[antlr-interest] Buglet in literal escaping
Johannes Luber
jaluber at gmx.de
Thu Feb 12 11:27:06 PST 2009
Jim Idle schrieb:
> Johannes Luber wrote:
>>> Using '\\"' as a literal in an ANTLR grammar causes ANTLRv3.1.1 to emit:
>>> match("\\"")
>>> which is an unterminated string constant. Oops!
>>>
>>
>> That's no bug, ANTLR does exactly what it is supposed to do. I think you want to use "\\\"" instead.
>>
> In fact it was a bug in 3.1.1, take a look at the sequence again :-) It
> is a correct spec, assuming that Scott wants to match backslash followed
> by doublequote. ANTLR strings are in single quotes and there is no need
> to escape double quotes.
>
> Jim
But that would suppose that ANTLR would escape the " on its own? And in
Java \\\" equals \", so I wasn't completely off target. :)
Johannes
More information about the antlr-interest
mailing list