mirror of https://gitlab.com/qemu-project/qemu
qapi: Prepare for catching more semantic parse errors
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>
This commit is contained in:
parent
44bd1276a7
commit
268a1c5eb1
|
@ -399,6 +399,7 @@ def check_exprs(schema):
|
||||||
check_event(expr, info)
|
check_event(expr, info)
|
||||||
|
|
||||||
def parse_schema(input_file):
|
def parse_schema(input_file):
|
||||||
|
# First pass: read entire file into memory
|
||||||
try:
|
try:
|
||||||
schema = QAPISchema(open(input_file, "r"))
|
schema = QAPISchema(open(input_file, "r"))
|
||||||
except (QAPISchemaError, QAPIExprError), e:
|
except (QAPISchemaError, QAPIExprError), e:
|
||||||
|
@ -407,6 +408,8 @@ def parse_schema(input_file):
|
||||||
|
|
||||||
exprs = []
|
exprs = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Next pass: learn the types.
|
||||||
for expr_elem in schema.exprs:
|
for expr_elem in schema.exprs:
|
||||||
expr = expr_elem['expr']
|
expr = expr_elem['expr']
|
||||||
if expr.has_key('enum'):
|
if expr.has_key('enum'):
|
||||||
|
@ -424,7 +427,7 @@ def parse_schema(input_file):
|
||||||
if not discriminator_find_enum_define(expr):
|
if not discriminator_find_enum_define(expr):
|
||||||
add_enum('%sKind' % expr['union'])
|
add_enum('%sKind' % expr['union'])
|
||||||
|
|
||||||
try:
|
# Final pass - validate that exprs make sense
|
||||||
check_exprs(schema)
|
check_exprs(schema)
|
||||||
except QAPIExprError, e:
|
except QAPIExprError, e:
|
||||||
print >>sys.stderr, e
|
print >>sys.stderr, e
|
||||||
|
|
Loading…
Reference in New Issue