[antlr-interest] newbie question: throwing an exception from parsing behavior
Blake Meike
bmeike at speakeasy.net
Sun Feb 24 19:05:50 PST 2008
Yeah, I tried something like that... RecognitionException does not
take that second argument.
I can, of course, catch my subclass, explicitly, and print out its
message. I was hoping there was some way to integrate with antlr's
error handling mechanism...
-blake
On Feb 24, 2008, at 5:40 PM, Olivier Lefevre wrote:
> Blake Meike wrote:
>> It all works fine, except that I can't figure our how to throw a
>> useful exception, when the input is invalid.
>
> From within an action. Subclass RecognitionException to add a
> message string or whatever and, in the action, do
>
> if (bad) throw new MyException(input, myMsg);
>
> All parsers have an input variable (inherited from Parser).
>
> -- O.L.
>
>
More information about the antlr-interest
mailing list