mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 12:23:53 -06:00
qapi: Improve reporting of lexical errors
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 <armbru@redhat.com> Message-Id: <20190914153506.2151-9-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
9f5e6b088a
commit
14c3279502
3 changed files with 7 additions and 3 deletions
|
@ -559,7 +559,11 @@ class QAPISchemaParser(object):
|
||||||
self.line += 1
|
self.line += 1
|
||||||
self.line_pos = self.cursor
|
self.line_pos = self.cursor
|
||||||
elif not self.tok.isspace():
|
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):
|
def get_members(self):
|
||||||
expr = OrderedDict()
|
expr = OrderedDict()
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
tests/qapi-schema/bad-type-int.json:3:13: Stray '1'
|
tests/qapi-schema/bad-type-int.json:3:13: Stray '123'
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
tests/qapi-schema/funny-word.json:1:3: Stray 'c'
|
tests/qapi-schema/funny-word.json:1:3: Stray 'command'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue