I have implemented this feature in my local copy of the C# port of the ANTLR tool, but I still need to make a decision about a couple aspects of it. Due to the declaration of BaseRecognizer.mTokens, non-fragment rules in a lexer that uses the Java target cannot specify user exceptions.
This condition only applies to the Java target, and even then a user could derive from a class other than BaseRecognizer as a workaround. Based on this, the following conditions need to be considered: * All parser rules may have user-specified exceptions in the exceptions specification (nothing to decide on here) * In theory, all fragment rules in a lexer can have user-specified exceptions, as long as they are handled by the non-fragment lexer rules that reference them. Should we allow this? * In theory, non-fragment lexer rules can specify user exceptions so long as the generated class derives from a user-created class where the mTokens function declares other exceptions. Other targets such as C# are not limited like this, and the exceptions spec would only be used as part of an XML comment at the function declaration. Should we allow this in the grammar? Sam -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Peter C. Chapin Sent: Wednesday, January 14, 2009 6:32 AM Cc: antlr-interest Subject: Re: [antlr-interest] Passing user defined exceptions throughtheparser. Sam Harwell wrote: > I just checked and the feature is not implemented in the code generator > yet. At least in the C# port of the tool it will cause recognition > exceptions if you use it in a grammar right now. > Okay, thanks for pointing this out. I'll take a look and keep my eye on it. Peter > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Sam Harwell > Sent: Tuesday, January 13, 2009 10:06 AM > To: Peter C. Chapin > Cc: antlr-interest > Subject: Re: [antlr-interest] Passing user defined exceptions through > theparser. > > There is a throwsSpec in the ANTLR tool grammar that *should* be able to > be used like this: > > my_rule /*returns [Object o]*/ throws RecognitionException, > OperationCanceledException > : ... > ; > > It doesn't apply to C# so it's not implemented in my CSharp3 target. > > Sam > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
