[antlr-interest] Fwd: changing the language ofdefault error handler for c++ parser

Ric Klaren klaren at cs.utwente.nl
Fri Sep 17 06:14:32 PDT 2004


On Fri, Sep 17, 2004 at 02:07:41PM +0200, Peter Sprenger wrote:
> I recently had the task to generate syntax errors in a foreign
> language (german) in a ANTLR parser. Since the default error handling
> is ok, I do not wanted to write an exception handler for every rule by
> myself, I decided to change the default output only. Also I don't
> wanted to change the C++ runtime library. Then my Odyssey began. To
> override reportError() was easy. But a RecognitionException has not
> all information necessary in the base class. So we have to distinguish
> MismatchedTokenException and NoViableAltException via RTTI.

Doesn't it work to add multiple overloaded reportErrors for
MismatchedToken../NoViable.. to the generated lexer/parser/treeparser?

> My question is, did I miss something? Or is there no easier way to
> change the output of the default error handler? Perhaps the overall
> scheme should be changed to ease such a task.

The current scheme is not ideal. Also for multilanguage and
internationalization support the current setup is not sufficient. I guess
that a setup where the exceptions do not generate the message themselves
would be better.

Maybe dump all eror reporting into a single object that's shared between
all the lexers/parser/treeparsers in use, and delegate to it from
reportError and friends. I think Ross Bencina posted ways back a proposal
for improved error handling, I only never got to working on it. Basically
if you can cook up a sane proposal and implementation we're all ears :)

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
  Chaos always defeats order because it is better organized.
  --- Terry Pratchet



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list