[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/19] qapi: Improve reporting of lexical errors
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 08/19] qapi: Improve reporting of lexical errors |
Date: |
Sat, 14 Sep 2019 17:34:55 +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>
---
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
- [Qemu-devel] [PATCH 03/19] tests/qapi-schema: Demonstrate misleading optional tag error, (continued)
- [Qemu-devel] [PATCH 03/19] tests/qapi-schema: Demonstrate misleading optional tag error, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 14/19] qapi: Simplify check_keys(), Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 12/19] qapi: Fix missing 'if' checks in struct, union, alternate 'data', Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 10/19] qapi: Fix broken discriminator error messages, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 02/19] tests/qapi-schema: Delete two redundant tests, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 08/19] qapi: Improve reporting of lexical errors,
Markus Armbruster <=
- [Qemu-devel] [PATCH 11/19] qapi: Reject blank 'if' conditions in addition to empty ones, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 06/19] tests/qapi-schema: Demonstrate suboptimal lexical errors, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 04/19] tests/qapi-schema: Demonstrate broken discriminator errors, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 18/19] qapi: Fix excessive QAPISchemaEntity.check() recursion, Markus Armbruster, 2019/09/14