antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
16.96k stars 3.26k forks source link

How antlr turns off runtime error logging #4360

Open yaosheng-zhang opened 1 year ago

yaosheng-zhang commented 1 year ago

How to turn off the log output shown in the image? 微信图片_20230719094105

jimidle commented 1 year ago

This is the output from the default error reporter - it is telling you that your input is syntactically incorrect. You can clear the error handlers on the parser object and it will stop telling you that, but your input will still be incorrect (or your grammar is incorrect).

Most people install their own error handler to gather errors in a way that makes more sense for their application. Look at the source code for the default error handler for clues.

On Wed, Jul 19, 2023 at 9:42 AM Yaosheng Zhang @.***> wrote:

How to turn off the log output shown in the image? [image: 微信图片_20230719094105] https://user-images.githubusercontent.com/107973056/254439026-c25d3f76-6ce2-444e-88cb-1c8ab731fbfb.png

— Reply to this email directly, view it on GitHub https://github.com/antlr/antlr4/issues/4360, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ7TMHVRDNYFQB4NDZBE63XQ43ORANCNFSM6AAAAAA2PFKULA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

aldoKelvianto commented 4 months ago

Use either parser.removeErrorListeners() or lexer.removeErrorListener(ConsoleErrorListener.INSTANCE);

As mentioned here: https://stackoverflow.com/a/35286575/1760984