[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/37] qapi: Improve reporting of lexical errors
From: |
Markus Armbruster |
Subject: |
[PULL 26/37] qapi: Improve reporting of lexical errors |
Date: |
Tue, 24 Sep 2019 14:33:23 +0200 |
Show text up to next structural character, whitespace, or quote
character instead of just the first character.
Forgotten quotes now get reported like "Stray 'command'" instead of
"Stray 'c'".
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
scripts/qapi/common.py | 6 +++++-
tests/qapi-schema/bad-type-int.err | 2 +-
tests/qapi-schema/funny-word.err | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 142ab276ff..b3383b17ef 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -559,7 +559,11 @@ class QAPISchemaParser(object):
self.line += 1
self.line_pos = self.cursor
elif not self.tok.isspace():
- raise QAPIParseError(self, "Stray '%s'" % self.tok)
+ # Show up to next structural, whitespace or quote
+ # character
+ match = re.match('[^[\\]{}:,\\s\'"]+',
+ self.src[self.cursor-1:])
+ raise QAPIParseError(self, "Stray '%s'" % match.group(0))
def get_members(self):
expr = OrderedDict()
diff --git a/tests/qapi-schema/bad-type-int.err
b/tests/qapi-schema/bad-type-int.err
index 2021fda5d1..9b2c12c1eb 100644
--- a/tests/qapi-schema/bad-type-int.err
+++ b/tests/qapi-schema/bad-type-int.err
@@ -1 +1 @@
-tests/qapi-schema/bad-type-int.json:3:13: Stray '1'
+tests/qapi-schema/bad-type-int.json:3:13: Stray '123'
diff --git a/tests/qapi-schema/funny-word.err b/tests/qapi-schema/funny-word.err
index 18aedb4a99..af92fe2551 100644
--- a/tests/qapi-schema/funny-word.err
+++ b/tests/qapi-schema/funny-word.err
@@ -1 +1 @@
-tests/qapi-schema/funny-word.json:1:3: Stray 'c'
+tests/qapi-schema/funny-word.json:1:3: Stray 'command'
--
2.21.0
- [PULL 06/37] docs/devel/qapi-code-gen: Minor specification fixes, (continued)
- [PULL 06/37] docs/devel/qapi-code-gen: Minor specification fixes, Markus Armbruster, 2019/09/24
- [PULL 11/37] qapi: Permit alternates with just one branch, Markus Armbruster, 2019/09/24
- [PULL 19/37] tests/qapi-schema: Cover unknown pragma, Markus Armbruster, 2019/09/24
- [PULL 29/37] qapi: Reject blank 'if' conditions in addition to empty ones, Markus Armbruster, 2019/09/24
- [PULL 35/37] qapi: Fix to .check() empty structs just once, Markus Armbruster, 2019/09/24
- [PULL 33/37] qapi: Clean up around check_known_keys(), Markus Armbruster, 2019/09/24
- [PULL 32/37] qapi: Simplify check_keys(), Markus Armbruster, 2019/09/24
- [PULL 34/37] qapi: Delete useless check_exprs() code for simple union kind, Markus Armbruster, 2019/09/24
- [PULL 27/37] qapi: Remove null from schema language, Markus Armbruster, 2019/09/24
- [PULL 13/37] qapi: Adjust frontend errors to say enum value, not member, Markus Armbruster, 2019/09/24
- [PULL 26/37] qapi: Improve reporting of lexical errors,
Markus Armbruster <=
- [PULL 10/37] qapi: Permit 'boxed' with empty type, Markus Armbruster, 2019/09/24
- [PULL 37/37] qapi: Assert .visit() and .check_clash() run only after .check(), Markus Armbruster, 2019/09/24
- [PULL 22/37] tests/qapi-schema: Demonstrate broken discriminator errors, Markus Armbruster, 2019/09/24
- [PULL 03/37] scripts/git.orderfile: Match QAPI schema more precisely, Markus Armbruster, 2019/09/24
- [PULL 12/37] qapi: Permit omitting all flat union branches, Markus Armbruster, 2019/09/24
- [PULL 15/37] docs/devel/qapi-code-gen: Rewrite compatibility considerations, Markus Armbruster, 2019/09/24
- [PULL 20/37] tests/qapi-schema: Delete two redundant tests, Markus Armbruster, 2019/09/24
- [PULL 24/37] tests/qapi-schema: Demonstrate suboptimal lexical errors, Markus Armbruster, 2019/09/24
- [PULL 09/37] qapi: Drop support for escape sequences other than \\, Markus Armbruster, 2019/09/24
- [PULL 21/37] tests/qapi-schema: Demonstrate misleading optional tag error, Markus Armbruster, 2019/09/24