[antlr-interest] Wondering about: Error handling
Terence Parr
parrt at cs.usfca.edu
Sun Jun 17 17:14:35 PDT 2007
On Jun 18, 2007, at 6:13 AM, Oliver Zeigermann wrote:
> When I want special handling for certain exceptions only I can specify
> that in the catch phrase. Like that:
>
> catch [FailedPredicateException fpe] {
> ...
> }
>
> However, this replaces the orignal catch block instead of being added.
> I expected something like this to be generated:
>
>
> catch (FailedPredicateException fpe) {
> ...
> }
> catch (RecognitionException re) {
> reportError(re);
> recover(input,re);
> }
>
> But only the first block actually is generated.
Interesting. Hmm...I guess that was my intended behaviour but I can
see how it would be confusing. OTOH, I can't always look at the
exception names inside and determine for an arbitrary target what's
up. In fact, ANTLR's code generator can't assume anything. The
templates can change the generic Recog. exception to be anything.
Something could be done via templates, but...at the very least we
should document it. ;)
Ter
More information about the antlr-interest
mailing list