From 636eec8f51b3fa19e32563f718749273e4b73315 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Sat, 11 May 2013 13:59:19 -0400 Subject: [PATCH] style fixes --- hy/compiler.py | 26 +++++++++++++++----------- tests/__init__.py | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 7602b30..78c5d94 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -35,6 +35,7 @@ from hy.models.float import HyFloat from hy.models.list import HyList from hy.models.dict import HyDict +import hy.importer from hy.core import process from hy.util import str_type @@ -93,6 +94,14 @@ def ast_str(foobar): def builds(_type): + + unpythonic_chars = ["-"] + really_ok = ["-"] + if True in (x in str_type(_type) for x in unpythonic_chars): + if _type not in really_ok: + raise TypeError("`build' needs to be *post* translated strings, " + "Mr. / Mrs. Hypser. -- `%s' sucks." % (_type)) + def _dec(fn): _compile_table[_type] = fn return fn @@ -569,7 +578,7 @@ class HyASTCompiler(object): return ret @builds("unquote") - @builds("unquote-splicing") + @builds("unquote_splicing") def compile_unquote(self, expr): raise HyTypeError(expr, "`%s' can't be used at the top-level" % expr[0]) @@ -1595,9 +1604,8 @@ class HyASTCompiler(object): expression.pop(0) name = expression.pop(0) if not isinstance(name, HySymbol): - raise HyTypeError(name, - ("received a `%s' instead of a symbol " - "for macro name" % type(name).__name__)) + raise HyTypeError(name, ("received a `%s' instead of a symbol " + "for macro name" % type(name).__name__)) name = HyString(name).replace(name) new_expression = HyExpression([ HySymbol("do"), @@ -1607,15 +1615,11 @@ class HyASTCompiler(object): ]), HyExpression([ HySymbol("with_decorator"), - HyExpression([ - HySymbol("hy.macros.macro"), - name, - ]), - HyExpression([HySymbol("fn")] + - expression), + HyExpression([HySymbol("hy.macros.macro"), name]), + HyExpression([HySymbol("fn")] + expression), ]), ]).replace(expression) - + hy.importer.hy_eval(new_expression, {}) return self.compile(new_expression) @builds(HyInteger) diff --git a/tests/__init__.py b/tests/__init__.py index 3290f8c..7d8dff8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -4,6 +4,7 @@ import hy # noqa from .native_tests.defclass import * # noqa from .native_tests.math import * # noqa +from .native_tests.native_macros import * # noqa from .native_tests.quote import * # noqa from .native_tests.language import * # noqa from .native_tests.unless import * # noqa