[antlr-interest] C# Error Recovery

Thomas Brandon tbrandonau at gmail.com
Thu Apr 17 11:52:35 PDT 2008


On Fri, Apr 18, 2008 at 3:58 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
>
>  On Apr 17, 2008, at 10:12 AM, Johannes Luber wrote:
>
> > Not entirely stylistic. After all, Ter used procedural programming in a
> place, which could benefit from polymorphism. Having a catch-all clause
> doesn't very well with me. Using the compiler to choose the right text
> message is easier and one might not have to override getErrorMessage().
> >
>
>  I disagree...Another example of people thinking objects of the answer to
> everything. Okay so subclass all of the exceptions in your application. Now,
> how are you going to get ANTLR to generate those exceptions instead of the
> standard ones? You will now have to go modify all the templates and runtime
> code to be able to deal with exception factories or something else. Having
> all error messages handled through one method is extremely appropriate
> because it groups everything into one location and makes it much easier to
> internationalize using templates and so on.
>
>  As you can tell for my comment on that function, I thought about it quite a
> bit. I even tried it the other way.
>
>  Ter
>
Well I'm not sure it couldn't be implemented just as cleanly with a
single exception creation factory (where template code ould be added
easily in one place and a simpler message output function. But even if
that is possible that requires quite widespread changes to ANTLR and
doesn't seem to offer any advatage or be much cleaner. However I think
the seperate suggestion of having the getErrorMessage function use the
message of exceptions of an unkown type (rather than defaulting to
null in these cases currently) is reasonable and you don't seem to
have dealt with this.

Tom.


More information about the antlr-interest mailing list