From a7627f22ece738c3df8cb6c3d1502c7e9b20dbf2 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sun, 27 Nov 2011 11:55:32 +0000 Subject: Support expression lists (e.g. 1, 2, 3) --- pp2cc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'pp2cc.py') diff --git a/pp2cc.py b/pp2cc.py index c050cf6..ff81fc5 100755 --- a/pp2cc.py +++ b/pp2cc.py @@ -754,6 +754,11 @@ class Parse(object): # } lines.append(self.asm.noop(lbl_for_end)) return lines + def parseExprList(self, linked_node): + lines = [] + for expr in linked_node.node.exprs: + lines += self.parseStatement(expr, linked_node) + return lines def parseStatement(self, node, parent_linked_node, level_increment=False): linked_node = LinkedNode(node, parent_linked_node, level_increment=level_increment) self.asm.level = linked_node.level @@ -762,8 +767,6 @@ class Parse(object): raise RuntimeError("Not implemented for type " + repr(node)) elif isinstance(node, c_ast.Decl): self.defineGlobalVar(linked_node, parent_linked_node) - elif isinstance(node, c_ast.ExprList): - raise RuntimeError("Not implemented for type " + repr(node)) elif isinstance(node, c_ast.FuncDecl): raise RuntimeError("Not implemented for type " + repr(node)) elif isinstance(node, c_ast.PtrDecl): @@ -771,7 +774,7 @@ class Parse(object): else: for entry in ("Compound", "BinaryOp", "If", "Constant", "ID", "Return", "FuncCall", "UnaryOp", "Cast", - "TernaryOp", "DoWhile", "While", "For"): + "TernaryOp", "DoWhile", "While", "For", "ExprList"): if isinstance(node, getattr(c_ast, entry)): lines += getattr(self, "parse" + entry)(linked_node) break -- cgit v1.2.1