Reputation: 312
Is there is any way to turnoff the mismatch or no viable alternative warning/errors in antlr4.
For example while parsing an input file suppose I'm getting these kind of infos:
line 377:4 no viable alternative at input ',PRIMARY KEY'
line 579:35 no viable alternative at input '1'
Is there is any way to turnoff these warnings ???
Upvotes: 0
Views: 1276
Reputation: 99859
To simply turn them off, call lexer.removeErrorListeners()
and parser.removeErrorListeners()
. Typically when you do that, you want to follow it with a call to add your own implementation of ANTLRErrorListener
that reports the errors in a manner that makes sense for your specific application.
Upvotes: 3
Reputation: 5962
You can provide an ErrorListener implementation to the parser and then override the appropriate methods to simply ignore the events. Note that you can also provide an ErrorStrategy to customize how it handles errors during the parse before it announces them.
Upvotes: 0