qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 12/40] qapi: Prepare for catching more semantic parse errors
Date: Tue,  5 May 2015 18:46:58 +0200	[thread overview]
Message-ID: <1430844446-12491-13-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1430844446-12491-1-git-send-email-armbru@redhat.com>

From: Eric Blake <eblake@redhat.com>

This patch widens the scope of a try block (with the attending
reindentation required by Python) in preparation for a future
patch adding more instances of QAPIExprError inside the block.
It's easier to separate indentation from semantic changes, so
this patch has no real behavior change.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 5f0f699..0c3459b 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -399,6 +399,7 @@ def check_exprs(schema):
             check_event(expr, info)
 
 def parse_schema(input_file):
+    # First pass: read entire file into memory
     try:
         schema = QAPISchema(open(input_file, "r"))
     except (QAPISchemaError, QAPIExprError), e:
@@ -407,24 +408,26 @@ def parse_schema(input_file):
 
     exprs = []
 
-    for expr_elem in schema.exprs:
-        expr = expr_elem['expr']
-        if expr.has_key('enum'):
-            add_enum(expr['enum'], expr.get('data'))
-        elif expr.has_key('union'):
-            add_union(expr)
-        elif expr.has_key('type'):
-            add_struct(expr)
-        exprs.append(expr)
-
-    # Try again for hidden UnionKind enum
-    for expr_elem in schema.exprs:
-        expr = expr_elem['expr']
-        if expr.has_key('union'):
-            if not discriminator_find_enum_define(expr):
-                add_enum('%sKind' % expr['union'])
-
     try:
+        # Next pass: learn the types.
+        for expr_elem in schema.exprs:
+            expr = expr_elem['expr']
+            if expr.has_key('enum'):
+                add_enum(expr['enum'], expr.get('data'))
+            elif expr.has_key('union'):
+                add_union(expr)
+            elif expr.has_key('type'):
+                add_struct(expr)
+            exprs.append(expr)
+
+        # Try again for hidden UnionKind enum
+        for expr_elem in schema.exprs:
+            expr = expr_elem['expr']
+            if expr.has_key('union'):
+                if not discriminator_find_enum_define(expr):
+                    add_enum('%sKind' % expr['union'])
+
+        # Final pass - validate that exprs make sense
         check_exprs(schema)
     except QAPIExprError, e:
         print >>sys.stderr, e
-- 
1.9.3

  parent reply	other threads:[~2015-05-05 16:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-05 16:46 [Qemu-devel] [PULL 00/40] drop qapi nested structs Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 01/40] qapi: Add copyright declaration on docs Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 02/40] qapi: Document type-safety considerations Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 03/40] qapi: Simplify builtin type handling Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 04/40] qapi: Fix generation of 'size' builtin type Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 05/40] qapi: Require ASCII in schema Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 06/40] qapi: Add some enum tests Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 07/40] qapi: Better error messages for bad enums Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 08/40] qapi: Add some union tests Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 09/40] qapi: Clean up test coverage of simple unions Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 10/40] qapi: Forbid base without discriminator in unions Markus Armbruster
2015-05-05 16:46 ` [Qemu-devel] [PULL 11/40] qapi: Tighten checking of unions Markus Armbruster
2015-05-05 16:46 ` Markus Armbruster [this message]
2015-05-05 16:46 ` [Qemu-devel] [PULL 13/40] qapi: Segregate anonymous unions into alternates in generator Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 14/40] qapi: Rename anonymous union type in test Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 15/40] qapi: Document new 'alternate' meta-type Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 16/40] qapi: Use 'alternate' to replace anonymous union Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 17/40] qapi: Add some expr tests Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 18/40] qapi: Better error messages for bad expressions Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 19/40] qapi: Add tests of redefined expressions Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 20/40] qapi: Better error messages for duplicated expressions Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 21/40] qapi: Allow true, false and null in schema json Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 22/40] qapi: Unify type bypass and add tests Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 23/40] qapi: Add some type check tests Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 24/40] qapi: More rigourous checking of types Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 25/40] qapi: Require valid names Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 26/40] qapi: Whitelist commands that don't return dictionary Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 27/40] qapi: More rigorous checking for type safety bypass Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 28/40] qapi: Prefer 'struct' over 'type' in generator Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 29/40] qapi: Document 'struct' metatype Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 30/40] qapi: Use 'struct' instead of 'type' in schema Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 31/40] qapi: Forbid " Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 32/40] qapi: Merge UserDefTwo and UserDefNested in tests Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 33/40] qapi: Drop tests for inline nested structs Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 34/40] qapi: Drop inline nested struct in query-version Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 35/40] qapi: Drop inline nested structs in query-pci Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 36/40] qapi: Drop support for inline nested types Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 37/40] qapi: Drop dead visitor code related to nested structs Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 38/40] qapi: Tweak doc references to QMP when QGA is also meant Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 39/40] qapi: Support (subset of) \u escapes in strings Markus Armbruster
2015-05-05 16:47 ` [Qemu-devel] [PULL 40/40] qapi: Check for member name conflicts with a base class Markus Armbruster
2015-05-06 10:16 ` [Qemu-devel] [PULL 00/40] drop qapi nested structs Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430844446-12491-13-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).