This allows giving decimal constants in the schema as expr. Signed-off-by: Fam Zheng <f...@redhat.com> --- scripts/qapi.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py index b474c39..6022de5 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -108,6 +108,14 @@ class QAPISchema: return else: string += ch + elif self.tok in "123456789": + self.val = int(self.tok) + while True: + ch = self.src[self.cursor] + if ch not in "1234567890": + return + self.val = self.val * 10 + int(ch) + self.cursor += 1 elif self.tok == '\n': if self.cursor == len(self.src): self.tok = None @@ -147,8 +155,8 @@ class QAPISchema: if self.tok == ']': self.accept() return expr - if not self.tok in [ '{', '[', "'" ]: - raise QAPISchemaError(self, 'Expected "{", "[", "]" or string') + if not self.tok in "{['123456789": + raise QAPISchemaError(self, 'Expected "{", "[", "]", string or number') while True: expr.append(self.get_expr(True)) if self.tok == ']': @@ -170,6 +178,9 @@ class QAPISchema: elif self.tok == "'": expr = self.val self.accept() + elif self.tok in "123456789": + expr = self.val + self.accept() else: raise QAPISchemaError(self, 'Expected "{", "[" or string') return expr -- 1.9.2