[antlr-interest] lexer: embedded quotes assistance
Gavin Lambert
antlr at mirality.co.nz
Fri Aug 24 14:42:28 PDT 2007
At 04:23 25/08/2007, Edwards, Waverly wrote:
>I haven't figured out how to get ANTLR to tell me the string is
>unterminated but I will.
Well, by the first definition (that permits embedded NEWLINEs),
the only way a string could possibly be unterminated is if an EOF
occurs before the final quote -- in which case it should throw
some kind of RecognitionException, because it can't match the
final quote.
If embedded NEWLINEs are only permitted following the line
continuation character, then you really should add that to the
rule the way I described, to avoid having typos make strings
consume the remainder of the file.
I'm also a little surprised at how involved your replace calls
are. Doesn't Java have a "replace all" function already?
More information about the antlr-interest
mailing list