added new reportAttemptingFullContext to strategy
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9760]
This commit is contained in:
parent
9853061093
commit
d01bde9125
|
@ -134,7 +134,13 @@ public interface ANTLRErrorStrategy<Symbol> {
|
||||||
// int startIndex, int stopIndex, @NotNull IntervalSet ambigAlts,
|
// int startIndex, int stopIndex, @NotNull IntervalSet ambigAlts,
|
||||||
// @NotNull OrderedHashSet<ATNConfig> configs);
|
// @NotNull OrderedHashSet<ATNConfig> configs);
|
||||||
|
|
||||||
/** Called by the parser when it find a conflict that is resolved by retrying the parse
|
|
||||||
|
void reportAttemptingFullContext(@NotNull BaseRecognizer<Symbol> recognizer,
|
||||||
|
@NotNull DFA dfa,
|
||||||
|
int startIndex, int stopIndex,
|
||||||
|
@NotNull OrderedHashSet<ATNConfig> configs);
|
||||||
|
|
||||||
|
/** Called by the parser when it find a conflict that is resolved by retrying the parse
|
||||||
* with full context. This is not a warning; it simply notifies you that your grammar
|
* with full context. This is not a warning; it simply notifies you that your grammar
|
||||||
* is more complicated than Strong LL can handle. The parser moved up to full context
|
* is more complicated than Strong LL can handle. The parser moved up to full context
|
||||||
* parsing for that input sequence.
|
* parsing for that input sequence.
|
||||||
|
|
|
@ -562,7 +562,15 @@ public class DefaultErrorStrategy<Symbol> implements ANTLRErrorStrategy<Symbol>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void reportAttemptingFullContext(@NotNull BaseRecognizer<Symbol> recognizer,
|
||||||
|
@NotNull DFA dfa,
|
||||||
|
int startIndex, int stopIndex,
|
||||||
|
@NotNull OrderedHashSet<ATNConfig> configs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void reportContextSensitivity(@NotNull BaseRecognizer<Symbol> recognizer, @NotNull DFA dfa,
|
public void reportContextSensitivity(@NotNull BaseRecognizer<Symbol> recognizer, @NotNull DFA dfa,
|
||||||
int startIndex, int stopIndex, @NotNull OrderedHashSet<ATNConfig> configs)
|
int startIndex, int stopIndex, @NotNull OrderedHashSet<ATNConfig> configs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,8 +49,18 @@ public class DiagnosticErrorStrategy<Symbol> extends DefaultErrorStrategy<Symbol
|
||||||
recognizer.getInputString(startIndex, stopIndex)+"'");
|
recognizer.getInputString(startIndex, stopIndex)+"'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reportContextSensitivity(@NotNull BaseRecognizer<Symbol> recognizer, @NotNull DFA dfa,
|
public void reportAttemptingFullContext(@NotNull BaseRecognizer<Symbol> recognizer,
|
||||||
|
@NotNull DFA dfa,
|
||||||
|
int startIndex, int stopIndex,
|
||||||
|
@NotNull OrderedHashSet<ATNConfig> configs)
|
||||||
|
{
|
||||||
|
recognizer.notifyListeners("reportAttemptingFullContext d="+dfa.decision +": "+ configs + ", input='" +
|
||||||
|
recognizer.getInputString(startIndex, stopIndex)+"'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reportContextSensitivity(@NotNull BaseRecognizer<Symbol> recognizer, @NotNull DFA dfa,
|
||||||
int startIndex, int stopIndex, @NotNull OrderedHashSet<ATNConfig> configs)
|
int startIndex, int stopIndex, @NotNull OrderedHashSet<ATNConfig> configs)
|
||||||
{
|
{
|
||||||
recognizer.notifyListeners("reportContextSensitivity d="+dfa.decision +": "+ configs + ", input='" +
|
recognizer.notifyListeners("reportContextSensitivity d="+dfa.decision +": "+ configs + ", input='" +
|
||||||
|
|
|
@ -602,6 +602,8 @@ public class v2ParserATNSimulator<Symbol> extends ATNSimulator {
|
||||||
boolean greedy)
|
boolean greedy)
|
||||||
{
|
{
|
||||||
retry_with_context++;
|
retry_with_context++;
|
||||||
|
reportAttemptingFullContext(dfa, s0, startIndex, input.index());
|
||||||
|
|
||||||
if ( debug ) System.out.println("execATNWithFullContext "+s0+", greedy="+greedy);
|
if ( debug ) System.out.println("execATNWithFullContext "+s0+", greedy="+greedy);
|
||||||
ATNConfigSet reach = null;
|
ATNConfigSet reach = null;
|
||||||
ATNConfigSet previous = s0;
|
ATNConfigSet previous = s0;
|
||||||
|
@ -1313,6 +1315,14 @@ public class v2ParserATNSimulator<Symbol> extends ATNSimulator {
|
||||||
// if ( parser!=null ) parser.getErrorHandler().reportConflict(parser, startIndex, stopIndex, alts, configs);
|
// if ( parser!=null ) parser.getErrorHandler().reportConflict(parser, startIndex, stopIndex, alts, configs);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public void reportAttemptingFullContext(DFA dfa, ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||||
|
if ( debug || retry_debug ) {
|
||||||
|
System.out.println("reportAttemptingFullContext decision="+dfa.decision+":"+configs+
|
||||||
|
", input="+parser.getInputString(startIndex, stopIndex));
|
||||||
|
}
|
||||||
|
if ( parser!=null ) parser.getErrorHandler().reportContextSensitivity(parser, dfa, startIndex, stopIndex, configs);
|
||||||
|
}
|
||||||
|
|
||||||
public void reportContextSensitivity(DFA dfa, ATNConfigSet configs, int startIndex, int stopIndex) {
|
public void reportContextSensitivity(DFA dfa, ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||||
if ( debug || retry_debug ) {
|
if ( debug || retry_debug ) {
|
||||||
System.out.println("reportContextSensitivity decision="+dfa.decision+":"+configs+
|
System.out.println("reportContextSensitivity decision="+dfa.decision+":"+configs+
|
||||||
|
|
Loading…
Reference in New Issue