ANTLR 4: Avoid error printing to console
You can check what listeners you have
for (ANTLRErrorListener listener : parser.getErrorListeners()) {
System.out.println(listener);
}
Look for ConsoleErrorListener
.
By default, ConsoleListener
is activated [1].
You can remove it in your code:
lexer.removeErrorListener(ConsoleErrorListener.INSTANCE);
[1] https://github.com/antlr/antlr4/blob/master/runtime/Java/src/org/antlr/v4/runtime/Recognizer.java#L56 (see add(ConsoleErrorListener.INSTANCE);
)