Short version:
I am using
parser.addErrorListener(new DiagnosticErrorListener());
parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
But when I run my parser I don't see any output to the affect of 'reportAmbiguity ...' as the ANTLR4 book shows. How can I see ambiguities in my grammar?
Long version:
The parsing speed I currently get with ANTLR4 is around 90kb/s on a 8-core 2.67ghz Xeon E5640 machine. The lexing speed is about 5mb/s, so that is fine. While trying to optimize my parser I discovered two stage parsing, where the first stage parses using PredictionMode.SLL, and if that fails then the second stage uses PredictionMode.LL. Using these two modes works, and I see some inputs succeed with SLL in less time than they would have taken with LL.
The issue is I would like all (or most) to succeed with SLL. I assume I need to remove ambiguities from my grammar to accomplish this. I would like ANTLR4 to tell me about any ambiguities so that I may resolve them.
I was facing same problem when I removed ConsoleErrorListener
with parser.removeErrorListener();
. You can check you listeners with code bellow
for (ANTLRErrorListener listener : parser.getErrorListeners()) {
System.out.println(listener);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With