while loop

This commit is contained in:
Paul Tagliamonte 2012-12-22 21:47:38 -05:00
parent 63a276692a
commit 952ba5811e

View File

@ -123,7 +123,10 @@ class AST27Converter(object):
"def": self._def,
"import": _ast_import,
"doseq": self._ast_for, "for": self._ast_for,
"while": self._ast_while,
"doseq": self._ast_for,
"for": self._ast_for,
}
def _def(self, node):
@ -139,6 +142,22 @@ class AST27Converter(object):
)
return ret
def _ast_while(self, node):
i = node.get_invocation()
args = i['args']
test = args.pop(0)
test = self.render(test)
body = args.pop(0)
body = self.render(body)
body = body if isinstance(body, list) else [body]
return ast.While(
test=test,
body=body,
orelse=[]
)
def _ast_for(self, node):
i = node.get_invocation()
args = i['args']