style fixes

This commit is contained in:
Paul Tagliamonte 2013-05-11 13:59:19 -04:00
parent b380b330cd
commit 636eec8f51
2 changed files with 16 additions and 11 deletions

View File

@ -35,6 +35,7 @@ from hy.models.float import HyFloat
from hy.models.list import HyList from hy.models.list import HyList
from hy.models.dict import HyDict from hy.models.dict import HyDict
import hy.importer
from hy.core import process from hy.core import process
from hy.util import str_type from hy.util import str_type
@ -93,6 +94,14 @@ def ast_str(foobar):
def builds(_type): 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): def _dec(fn):
_compile_table[_type] = fn _compile_table[_type] = fn
return fn return fn
@ -569,7 +578,7 @@ class HyASTCompiler(object):
return ret return ret
@builds("unquote") @builds("unquote")
@builds("unquote-splicing") @builds("unquote_splicing")
def compile_unquote(self, expr): def compile_unquote(self, expr):
raise HyTypeError(expr, raise HyTypeError(expr,
"`%s' can't be used at the top-level" % expr[0]) "`%s' can't be used at the top-level" % expr[0])
@ -1595,8 +1604,7 @@ class HyASTCompiler(object):
expression.pop(0) expression.pop(0)
name = expression.pop(0) name = expression.pop(0)
if not isinstance(name, HySymbol): if not isinstance(name, HySymbol):
raise HyTypeError(name, raise HyTypeError(name, ("received a `%s' instead of a symbol "
("received a `%s' instead of a symbol "
"for macro name" % type(name).__name__)) "for macro name" % type(name).__name__))
name = HyString(name).replace(name) name = HyString(name).replace(name)
new_expression = HyExpression([ new_expression = HyExpression([
@ -1607,15 +1615,11 @@ class HyASTCompiler(object):
]), ]),
HyExpression([ HyExpression([
HySymbol("with_decorator"), HySymbol("with_decorator"),
HyExpression([ HyExpression([HySymbol("hy.macros.macro"), name]),
HySymbol("hy.macros.macro"), HyExpression([HySymbol("fn")] + expression),
name,
]),
HyExpression([HySymbol("fn")] +
expression),
]), ]),
]).replace(expression) ]).replace(expression)
hy.importer.hy_eval(new_expression, {})
return self.compile(new_expression) return self.compile(new_expression)
@builds(HyInteger) @builds(HyInteger)

View File

@ -4,6 +4,7 @@
import hy # noqa import hy # noqa
from .native_tests.defclass import * # noqa from .native_tests.defclass import * # noqa
from .native_tests.math import * # noqa from .native_tests.math import * # noqa
from .native_tests.native_macros import * # noqa
from .native_tests.quote import * # noqa from .native_tests.quote import * # noqa
from .native_tests.language import * # noqa from .native_tests.language import * # noqa
from .native_tests.unless import * # noqa from .native_tests.unless import * # noqa