[antlr-interest] Removing System.out and System.err calls

Terence Parr parrt at cs.usfca.edu
Fri Oct 26 18:18:57 PDT 2007


On Oct 25, 2007, at 6:49 PM, <Robert.Klaus at innovations.de>  
<Robert.Klaus at innovations.de> wrote:

> Hi,
>
> In the BaseRecognizer.class there are several calls to System.err and
> System.out. In ANTLR2 I could overwrite methods like "reportError" to
> take care of the messages myself.
> However this is not possible in ANTLR3, as some of these calls are in
> methods I think are better not overwritten (e.g.
> "recoverFromMismatchedToken").
> Would it be possible to delegate all reporting to dedicated methods,
> e.g. "public void reportError(String msg)"? This would allow users of
> ANTLR3 to switch off System.out calls or use their own logging  
> facility.

Howdy. All errors should actually go thru:

public void emitErrorMessage(String msg) {
                System.err.println(msg);
}

The

System.err.println("BR.recoverFromMismatchedToken");

you see is a debugging print. Ooops.   Actually, it's gone in my main  
line of code. so we're cool.

Are there others?  That's the only one I see.

Ter




More information about the antlr-interest mailing list