[antlr-interest] Problem catching exceptions in c# generated code
Johannes Luber
jaluber at gmx.de
Thu Feb 21 07:16:59 PST 2008
Ed Sykes schrieb:
>
> I've just tried moving the try catch into the lexer around the call to
> Antlr.Runtime.Match() and this seems to catch the exception. I'm
> confused as to why putting the code in the driver doesn't work, but
> moving the try catch to the lexer does.
>
> at least i have a workaround if i can't figure out how to get it working
> in the driver.
Now I believe I know what's your problem actually is. You are getting
exceptions in the lexer, but you aren't catching them because the catch
clause doesn't include the lexer. That would make sense as the lexing is
done separately from the parsing. There only one problem with the
theory: FillBuffer() is called by NextToken() is called by the parser.
So the exception should be on the call chain. Strange. Nonetheless test
it, because changing the generate code is always a bad idea, if there is
an other way.
And to your other question in the other email: ANTLR has a special
syntax for exceptions in its grammar, but that doesn't work yet.
Johannes
More information about the antlr-interest
mailing list