[antlr-interest] ANTLR C# port

Sam Harwell sharwell at pixelminegames.com
Thu May 19 13:42:52 PDT 2011


After the debugger stops where the exception is thrown, you can use the Step
Over command to step over each catch and finally block until the exception
is handled. Can you check this and let me know which catch block is actually
handling the exception?

 

 

From: Dilip Ranganathan [mailto:misc.usage at gmail.com] 
Sent: Friday, May 20, 2011 3:58 AM
To: Sam Harwell
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] ANTLR C# port

 

 

I may have miscommunicated something here. I have a very simple "Hello
World!" style grammar that I wrote to learn ANTLR. I deliberately fed the
lexer/parser wrong input to see what happens. I can see this exception being
caught by the parser (I forced the debugger to break into this exception by
explicitly listing this exception under Debug->Exceptions list in VS2010).
But the outer client code that fires off the parser (using ANTLRStringStream
and friends) is bracketed by try/catch blocks but never gets anything. This
probably makes sense if library code is eating those exceptions but if it
does, how can client code know something went wrong?

 

 

On Thu, May 19, 2011 at 5:52 AM, Sam Harwell <sharwell at pixelminegames.com>
wrote:

My initial guess is the exceptions are being thrown in the lexer. By
default, the implementation of NextToken in the lexer catches any
RecognitionException and handles it by skipping the invalid token. Custom
handling of the exception depends on exactly what you're trying to
accomplish. One way to start is adding the following rule to the end of your
lexer, which passes the invalid tokens to the lexer for handling.

INVALID_CHAR : . ;

Sam


-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Dilip Ranganathan

Sent: Wednesday, May 18, 2011 3:00 AM

To: antlr-interest at antlr.org
Subject: [antlr-interest] ANTLR C# port

Hi

I have been banging my head with Sam Harwell's Antlr C# port since morning.

SO far I have managed to integrate grammar compilation with Visual Studio
2010 following the instructions on this page:
http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases

However I am stuck with something for the moment. A simple test driver
program I wrote to test the generated lexer/parser doesn't report any kind
of error when I pass invalid input. That is, the generated parser code is
eating the exception and the output window only shows that a few first
chance exceptions were generated. Now I added these exceptions to
Debug->Exceptions list in VS 2010 (under CLR) and that way I was able to
make the debugger break into the offending code but I can't believe this is
the way to do it? Shouldn't I be seeing something on the console or at least
as an exception I must be able to catch and display exactly what was wrong
with my input?

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

 



More information about the antlr-interest mailing list