returnable stuf
This commit is contained in:
parent
e6d094fd40
commit
d5de7a480b
@ -172,18 +172,27 @@ class HyASTCompiler(object):
|
|||||||
|
|
||||||
@builds("for")
|
@builds("for")
|
||||||
def compile_for_expression(self, expression):
|
def compile_for_expression(self, expression):
|
||||||
|
ret_status = self.returnable
|
||||||
|
self.returnable = False
|
||||||
|
|
||||||
expression.pop(0) # for
|
expression.pop(0) # for
|
||||||
name, iterable = expression.pop(0)
|
name, iterable = expression.pop(0)
|
||||||
target = self.compile_symbol(name)
|
target = self.compile_symbol(name)
|
||||||
target.ctx = ast.Store()
|
target.ctx = ast.Store()
|
||||||
|
# support stuff like:
|
||||||
|
# (for [x [1 2 3 4]
|
||||||
|
# y [a b c d]] ...)
|
||||||
|
|
||||||
return ast.For(
|
ret = ast.For(lineno=expression.start_line,
|
||||||
lineno=expression.start_line,
|
col_offset=expression.start_column,
|
||||||
col_offset=expression.start_column,
|
target=target,
|
||||||
target=target,
|
iter=self.compile(iterable),
|
||||||
iter=self.compile(iterable),
|
body=self._mangle_branch([
|
||||||
body=self._mangle_branch([self.compile(x) for x in expression]),
|
self.compile(x) for x in expression]),
|
||||||
orelse=[])
|
orelse=[])
|
||||||
|
|
||||||
|
self.returnable = ret_status
|
||||||
|
return ret
|
||||||
|
|
||||||
@builds(HyList)
|
@builds(HyList)
|
||||||
def compile_list(self, expr):
|
def compile_list(self, expr):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user