Antlr: disable console logs from antlr

I want to somehow catch ANTLR errors and suppress them in my java logs.

I am new to ANTLR and using ANTLR3.4

I went through this one and I couldn't find methods like these.

lexer.removeErrorListeners();
lexer.addErrorListener(someListener());
parser.removeErrorListeners();
parser.addErrorListener(someListener());

      

Is there a way that I could suppress the ANTLR console error?

+3


source to share


1 answer


In ANTLR 3, you need to overrideBaseRecognizer.emitErrorMessage

to control how errors are printed. The listener mechanism was added in ANTLR 4 (which I highly recommend using as it is vastly superior to ANTLR 3).



+1


source







All Articles