[antlr-interest] Wondering about: Error handling
Wincent Colaiuta
win at wincent.com
Mon Jun 18 00:58:39 PDT 2007
El 18/6/2007, a las 2:14, Terence Parr escribió:
> 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.
At least as a straightforward workaround you can just include the
RecognitionException catch block in your own override if that's the
behaviour that you want...
Cheers,
Wincent
More information about the antlr-interest
mailing list