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

petesp2002 sprenger at moving-bytes.de
Fri Sep 17 07:21:58 PDT 2004


--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...> wrote:
> 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 le
xer/parser/treeparser?

I tried this, but somehow only the original reportErrors function was
called. Perhaps because all exception handler catch a
RecognitionException, their call to reportErrors is only of this type,
too.

> 
> > 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 :)

I am under pressure in my current project, but afterwards I will try
to find a solution.

Regards,

Pete

> 
> Cheers,
> 
> Ric
> --
>
-----+++++****************************************
*************+++++++++-------
>     ---- Ric Klaren ----- j.klaren at u... ----- +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