From fbbf74bc4e9d765dd651b62e554335e504f95927 Mon Sep 17 00:00:00 2001 From: parrt Date: Thu, 10 Nov 2011 12:21:08 -0800 Subject: [PATCH] add exception to recover() [git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9287] --- .../Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java | 6 ++++-- .../src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java b/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java index 166a954a5..f391e735b 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java +++ b/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java @@ -48,9 +48,11 @@ public interface ANTLRErrorStrategy { /** Resynchronize the parser by consuming tokens until we find one * in the resynchronization set--loosely the set of tokens that can follow - * the current rule. + * the current rule. The exception contains info you might want to + * use to recover better. */ - void recover(BaseRecognizer recognizer); + void recover(BaseRecognizer recognizer, + RecognitionException e); /** Make sure that the current lookahead symbol is consistent with * what were expecting at this point in the ATN. You can call this diff --git a/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java b/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java index fdc9cc152..dadabeee7 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java +++ b/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java @@ -103,7 +103,7 @@ public class DefaultANTLRErrorStrategy implements ANTLRErrorStrategy { * token that the match() routine could not recover from. */ @Override - public void recover(BaseRecognizer recognizer) { + public void recover(BaseRecognizer recognizer, RecognitionException e) { // System.out.println("recover in "+recognizer.getRuleInvocationStack()+ // " index="+recognizer.getInputStream().index()+ // ", lastErrorIndex="+