From 07d4105c191fdb7b0d8aaedde9cf94618ec12302 Mon Sep 17 00:00:00 2001 From: kosiakk Date: Wed, 4 Dec 2013 17:47:20 +0100 Subject: [PATCH] Failure on parse errors, issue #71 Solved by also searching for non-interval ranges Conflicts: docs/sphinx/_themes/bootstrap --- src/Dyna/Backend/Python/utils.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Dyna/Backend/Python/utils.py b/src/Dyna/Backend/Python/utils.py index 63bd66b..fb39057 100644 --- a/src/Dyna/Backend/Python/utils.py +++ b/src/Dyna/Backend/Python/utils.py @@ -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: -- 2.50.1