[Jython-checkins] jython (merge 2.5 -> default): Merge from 2.5.

frank.wierzbicki jython-checkins at python.org
Fri Mar 30 00:03:24 CEST 2012


http://hg.python.org/jython/rev/aab8ce176bdc
changeset:   6507:aab8ce176bdc
parent:      6505:967bfe23ac3c
parent:      6506:11f442c1e716
user:        Frank Wierzbicki <fwierzbicki at gmail.com>
date:        Thu Mar 29 15:02:30 2012 -0700
summary:
  Merge from 2.5.

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
@@ -191,11 +191,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);
 }
@@ -257,16 +268,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()
             }
         }
@@ -298,7 +309,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);
@@ -337,7 +348,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);
@@ -358,7 +369,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