[Jython-checkins] jython (2.5): Restore antlr error count for analysis, thanks Roman (smokxx)!
frank.wierzbicki
jython-checkins at python.org
Fri Mar 30 00:03:24 CEST 2012
http://hg.python.org/jython/rev/11f442c1e716
changeset: 6506:11f442c1e716
branch: 2.5
parent: 6504:c7f648b3e03a
user: Frank Wierzbicki <fwierzbicki at gmail.com>
date: Thu Mar 29 14:59:03 2012 -0700
summary:
Restore antlr error count for analysis, thanks Roman (smokxx)!
files:
NEWS | 1 +
grammar/Python.g | 25 +++++++--
src/org/python/antlr/RecordingErrorHandler.java | 1 -
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@
Jython 2.5.3b2
Bugs Fixed
+ - [ 1866 ] Parser does not have mismatch token error messages caught by BaseRecognizer
- [ 1837 ] gderived.py and template Ant target fail on Windows
- [ 1536 ] NPE in org.python.jsr223.PyScriptEngine:187
- [ 1640 ] cStringIO does not complain on getvalue after close
diff --git a/grammar/Python.g b/grammar/Python.g
--- a/grammar/Python.g
+++ b/grammar/Python.g
@@ -185,11 +185,22 @@
this.encoding = encoding;
}
+ @Override
+ public void reportError(RecognitionException e) {
+ // Update syntax error count and output error.
+ super.reportError(e);
+ errorHandler.reportError(this, e);
+ }
+
+ @Override
+ public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
+ // Do nothing. We record errors instead of printing them.
+ }
}
@rulecatch {
catch (RecognitionException re) {
- errorHandler.reportError(this, re);
+ reportError(re);
errorHandler.recover(this, input,re);
retval.tree = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
}
@@ -251,16 +262,16 @@
}
return state.token;
} catch (NoViableAltException nva) {
- errorHandler.reportError(this, nva);
+ reportError(nva);
errorHandler.recover(this, nva); // throw out current char and try again
} catch (FailedPredicateException fp) {
//XXX: added this for failed STRINGPART -- the FailedPredicateException
// hides a NoViableAltException. This should be the only
// FailedPredicateException that gets thrown by the lexer.
- errorHandler.reportError(this, fp);
+ reportError(fp);
errorHandler.recover(this, fp); // throw out current char and try again
} catch (RecognitionException re) {
- errorHandler.reportError(this, re);
+ reportError(re);
// match() routine has already called recover()
}
}
@@ -292,7 +303,7 @@
;
//XXX: this block is duplicated in three places, how to extract?
catch [RecognitionException re] {
- errorHandler.reportError(this, re);
+ reportError(re);
errorHandler.recover(this, input,re);
PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
retval.tree = new ErrorMod(badNode);
@@ -331,7 +342,7 @@
;
//XXX: this block is duplicated in three places, how to extract?
catch [RecognitionException re] {
- errorHandler.reportError(this, re);
+ reportError(re);
errorHandler.recover(this, input,re);
PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
retval.tree = new ErrorMod(badNode);
@@ -352,7 +363,7 @@
;
//XXX: this block is duplicated in three places, how to extract?
catch [RecognitionException re] {
- errorHandler.reportError(this, re);
+ reportError(re);
errorHandler.recover(this, input,re);
PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
retval.tree = new ErrorMod(badNode);
diff --git a/src/org/python/antlr/RecordingErrorHandler.java b/src/org/python/antlr/RecordingErrorHandler.java
--- a/src/org/python/antlr/RecordingErrorHandler.java
+++ b/src/org/python/antlr/RecordingErrorHandler.java
@@ -26,7 +26,6 @@
public List<RecognitionException> errs = new ArrayList<RecognitionException>();
public void reportError(BaseRecognizer br, RecognitionException re) {
- br.reportError(re);
errs.add(re);
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list