This should work if you make OperationCanceledException a subclass of
RecognitionException, which is a checked exception thrown by parser's
methods. Then the catch clause does its job.

c.

On Mon, Jan 12, 2009 at 11:14 PM, Peter C. Chapin <[email protected]> wrote:
> Sam Harwell wrote:
>
>> Here's what I do. This is with the C# target so there are probably a few
>> differences, but you'll get the idea.
>>
>> try
>> {
>>     MyLexer lexer = new MyLexer( new ANTLRStringStream( text ) );
>>     CommonTokenStream tokens = new CommonTokenStream( lexer );
>>     MyParser parser = new MyParser( tokens );
>>     parser.program();
>> }
>> catch ( OperationCanceledException )
>> {
>>     // ...
>> }
>>
>
> I'm thinking that this works in C# because C# does not have statically
> enforced exception specifications (I could be wrong... I know very
> little about C#). In Java an attempt to throw OperationCanceledException
> from a method invoked inside a rule will cause the parser to fail to
> compile because the parser methods don't declare that exception in their
> exception specifications.
>
> Peter
>
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to