]> hydra-www.ietfng.org Git - dyna2/commitdiff
Failure on parse errors, issue #71
authorkosiakk <github@kosenkov.com>
Wed, 4 Dec 2013 16:47:20 +0000 (17:47 +0100)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Thu, 27 Feb 2014 02:35:48 +0000 (21:35 -0500)
Solved by also searching for non-interval ranges

Conflicts:
docs/sphinx/_themes/bootstrap

src/Dyna/Backend/Python/utils.py

index 63bd66bfa3f0abda794b0e4814ead2cc10936173..fb3905774a79a09ae690ce09e8c9c5471724eb42 100644 (file)
@@ -257,9 +257,21 @@ def span_to_src(span, src=None):
     Utility for retrieving source code for Parsec error message (there is
     nothing specific about rules)
     """
-
-    [(filename, bl, bc, el, ec)] = re.findall(r'(.*):(\d+):(\d+)-\1:(\d+):(\d+)', span)
-
+    
+    # look for intervals like `filename:3:1-filename:3:6`
+    lines = re.findall(r'(.*):(\d+):(\d+)-\1:(\d+):(\d+)', span)
+    if lines:
+        [(filename, bl, bc, el, ec)] = lines
+    else:
+        # look for point-like errors as in `filename:3:1`
+        lines = re.findall(r'(.*):(\d+):(\d+)', span)
+        if not lines:
+            return []
+        
+        [(filename, bl, bc)] = lines
+        el = bl
+        ec = bc
+    
     (bl, bc, el, ec) = map(int, [bl, bc, el, ec])
 
     if not src: