[antlr-interest] Wondering about: Error handling
Oliver Zeigermann
oliver at zeigermann.de
Sun Jun 17 13:13:39 PDT 2007
Folks!
I understand that - by default - ANTLR generates something like this
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
as generic code for error handling. When you want something else you
can specify your own error handling block using
catch [...] {
...
}
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.
This leads to problems when "normal" recognition exceptions occur as
they are no longer handled by the default procedure, but rather are
passed on to calling rules.
Is this intented behavior? Does it make sense to have it like that?
Just wondering and cheers
Oliver
More information about the antlr-interest
mailing list