[antlr-interest] throwing non-antlr exceptions
Joachim Schrod
jschrod at acm.org
Tue Apr 12 05:32:32 PDT 2011
Joe Lemmer wrote:
>
> I'd like to throw a Non-Antlr exception from one of my rules in a Parser. I'm using ANTLR v3
> I've tried to find some documentation and came across some stuff for ANTLR v2 that says the following:
>
> To specify that your parser (or
> tree parser rule) can throw a non-ANTLR specific exception, use the
> exceptions clause. For example, here is a simple parser specification
> with a rule that throws MyException:
>
> class P extends Parser;
>
> a throws MyException
> : A
> ;
The "throws" keyword in a grammar (currently) has no effect.
(I don't know if that worked in v2, it doesn't in v3.)
There is no possibility to add a checked exception to a rule.
You must use RuntimeExceptions.
Joachim
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod Email: jschrod at acm.org
Roedermark, Germany
More information about the antlr-interest
mailing list