[antlr-interest] How to stop lexer reporting errors to standard output?
Vaclav Barta
vbar at comp.cz
Thu Aug 16 00:27:31 PDT 2007
Hi,
I'm writing a library (parsing SQL, among other things) using ANTLR
(3.0, C# target), and I'd like it not to try any error recovery, but
just throw an exception on invalid input (so that the library user can
decide what to do about the error). I've managed to suppress error
recovery by specifying an empty @rulecatch, but I still occasionally get
warnings on standard output, i.e.
SELECT '''
results in
line 1:10 mismatched character '<EOF>' expecting '''
How do I get rid of the message (while still failing to parse the
invalid input, of course)?
The lexer rule is AFAIK quite conventional
fragment
StringRun :
(~ '\'' )+
;
ASCIIStringLiteral :
'\'' { text = ""; }
( s = StringRun { text = $s.text; } )? '\''
( '\'' {
text = text + "\'";
} ( s = StringRun { text = text + $s.text; } )? '\''
)*
;
if that helps.
Bye
Vasek
More information about the antlr-interest
mailing list