qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH v2 2/7] qapi: Allow true, false and null in sche


From: Fam Zheng
Subject: [Qemu-devel] [RFC PATCH v2 2/7] qapi: Allow true, false and null in schema json
Date: Tue, 20 May 2014 17:07:56 +0800

Signed-off-by: Fam Zheng <address@hidden>
---
 scripts/qapi.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 4c945ad..0f275f3 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -171,7 +171,20 @@ class QAPISchema:
                     return
                 except Exception, e:
                     raise QAPISchemaError(self, 'Invalid number "%s": %s' % 
(val, e))
-
+            elif self.tok in "tfn":
+                val = self.src[self.cursor - 1:]
+                if val.startswith("true"):
+                    self.val = True
+                    self.cursor += 3
+                    return
+                elif val.startswith("false"):
+                    self.val = False
+                    self.cursor += 4
+                    return
+                elif val.startswith("null"):
+                    self.val = None
+                    self.cursor += 3
+                    return
             elif self.tok == '\n':
                 if self.cursor == len(self.src):
                     self.tok = None
@@ -211,8 +224,8 @@ class QAPISchema:
         if self.tok == ']':
             self.accept()
             return expr
-        if not self.tok in "{['-0123456789":
-            raise QAPISchemaError(self, 'Expected "{", "[", "]", string or 
number')
+        if not self.tok in "{['-0123456789tfn":
+            raise QAPISchemaError(self, 'Expected "{", "[", "]", string, 
number, boolean or "null"')
         while True:
             expr.append(self.get_expr(True))
             if self.tok == ']':
@@ -231,10 +244,7 @@ class QAPISchema:
         elif self.tok == '[':
             self.accept()
             expr = self.get_values()
-        elif self.tok == "'":
-            expr = self.val
-            self.accept()
-        elif self.tok in "-0123456789":
+        elif self.tok in "'0123456789-tfn":
             expr = self.val
             self.accept()
         else:
-- 
1.9.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]