diff --git a/bin/hy b/bin/hy index cf529d7..0a9af67 100755 --- a/bin/hy +++ b/bin/hy @@ -1,2 +1,6 @@ #!/usr/bin/env python +from hy.importer import import_file_to_module +import sys + +import_file_to_module("", sys.argv[1]) diff --git a/hy/compiler.py b/hy/compiler.py index 0748470..4270503 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -66,7 +66,7 @@ class HyASTCompiler(object): if self.returnable and len(tree) > 0: el = tree[0] if not isinstance(el, ast.stmt): - el = tree.pop() + el = tree.pop(0) ret.append(ast.Return(value=el, lineno=el.lineno, col_offset=el.col_offset)) @@ -170,6 +170,21 @@ class HyASTCompiler(object): col_offset=expression.start_column, targets=[name], value=what) + @builds("for") + def compile_for_expression(self, expression): + expression.pop(0) # for + name, iterable = expression.pop(0) + target = self.compile_symbol(name) + target.ctx = ast.Store() + + return ast.For( + lineno=expression.start_line, + col_offset=expression.start_column, + target=target, + iter=self.compile(iterable), + body=self._mangle_branch([self.compile(x) for x in expression]), + orelse=[]) + @builds(HyList) def compile_list(self, expr): return ast.List(