From 12f0c9d099e997c91a2622c25ce112632ef5e115 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Fri, 3 Feb 2012 11:22:25 +0200 Subject: Transform the AST to create a correct representation of the cases inside a switch statement --- pycparser/c_ast.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'pycparser/c_ast.py') diff --git a/pycparser/c_ast.py b/pycparser/c_ast.py index 5868b9b..a1c92fb 100644 --- a/pycparser/c_ast.py +++ b/pycparser/c_ast.py @@ -194,15 +194,16 @@ class Break(Node): attr_names = () class Case(Node): - def __init__(self, expr, stmt, coord=None): + def __init__(self, expr, stmts, coord=None): self.expr = expr - self.stmt = stmt + self.stmts = stmts self.coord = coord def children(self): nodelist = [] if self.expr is not None: nodelist.append(("expr", self.expr)) - if self.stmt is not None: nodelist.append(("stmt", self.stmt)) + for i, child in enumerate(self.stmts or []): + nodelist.append(("stmts[%d]" % i, child)) return tuple(nodelist) attr_names = () @@ -303,13 +304,14 @@ class DeclList(Node): attr_names = () class Default(Node): - def __init__(self, stmt, coord=None): - self.stmt = stmt + def __init__(self, stmts, coord=None): + self.stmts = stmts self.coord = coord def children(self): nodelist = [] - if self.stmt is not None: nodelist.append(("stmt", self.stmt)) + for i, child in enumerate(self.stmts or []): + nodelist.append(("stmts[%d]" % i, child)) return tuple(nodelist) attr_names = () -- cgit v1.2.1