summaryrefslogtreecommitdiff
path: root/pycparser/c_ast.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2012-02-03 11:22:25 +0200
committerEli Bendersky <eliben@gmail.com>2012-02-03 11:22:25 +0200
commit12f0c9d099e997c91a2622c25ce112632ef5e115 (patch)
treeadeaf93e542e7a3d536637f47ce99c6414a392cb /pycparser/c_ast.py
parent5433326654f0f266fa692c6f76477ea0accde6f8 (diff)
downloadpycparser-12f0c9d099e997c91a2622c25ce112632ef5e115.tar.gz
Transform the AST to create a correct representation of the cases inside a switch statement
Diffstat (limited to 'pycparser/c_ast.py')
-rw-r--r--pycparser/c_ast.py14
1 files changed, 8 insertions, 6 deletions
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 = ()