From da234b1d8f3474a98566f18b8c2ff5fc1d39a232 Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Tue, 5 Mar 2013 22:08:53 -0500 Subject: [PATCH] adding in thingers. --- hy/compiler.py | 11 ++++++++++- tests/__init__.py | 1 + tests/native_tests/language.hy | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/native_tests/language.hy diff --git a/hy/compiler.py b/hy/compiler.py index 81af3fd..0748470 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -21,9 +21,10 @@ from hy.errors import HyError from hy.models.expression import HyExpression -from hy.models.symbol import HySymbol from hy.models.integer import HyInteger from hy.models.string import HyString +from hy.models.symbol import HySymbol +from hy.models.list import HyList import ast @@ -169,6 +170,14 @@ class HyASTCompiler(object): col_offset=expression.start_column, targets=[name], value=what) + @builds(HyList) + def compile_list(self, expr): + return ast.List( + elts=[self.compile(x) for x in expr], + ctx=ast.Load(), + lineno=expr.start_line, + col_offset=expr.start_column) + @builds("fn") def compile_fn_expression(self, expression): expression.pop(0) # fn diff --git a/tests/__init__.py b/tests/__init__.py index 9699570..244456c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -2,3 +2,4 @@ import hy from .native_tests.math import * +from .native_tests.language import * diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy new file mode 100644 index 0000000..8acb0f0 --- /dev/null +++ b/tests/native_tests/language.hy @@ -0,0 +1,4 @@ +; + +(def test_lists (fn [] + (assert (= [1 2 3 4] (+ [1 2] [3 4])))))