[antlr-interest] Throwing a exception in a rule

Alexandre Hamez alexandre.hamez at lip6.fr
Wed Aug 29 05:50:43 PDT 2007


On 29 août 07, at 14:43, Gavin Lambert wrote:

> At 00:30 30/08/2007, Alexandre Hamez wrote:
> >I try to declare a rule that throws an exception, but when I look
> >at the generated code, the corresponding method doesn't throws this
> >exception. The code is the following:
> [...]
> >So, am I missing something?
>
> IIRC, currently v3 does not implement throw specs.  (And I'm not  
> sure if it supports catch blocks yet either.)
>
> The simplest workaround at the moment is to make sure that whatever  
> you're trying to throw derives from RecognitionException.  (If need  
> be you can catch it outside the lexer/parser and convert it to some  
> other type if you don't want other code to have to deal with  
> RecognitionExceptions.)

Argh... Bad surprise :-(  So this information shouldn't be in the  
documentation :-D
Anyway, thanks for the tip :-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2429 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20070829/83e29d56/attachment.bin 


More information about the antlr-interest mailing list