Merge remote-tracking branch 'paultag/feature/native-macros' into feature/native-macros
Conflicts: hy/compiler.py tests/__init__.py
This commit is contained in:
commit
31c14e4167
@ -94,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
|
||||||
@ -570,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])
|
||||||
@ -1596,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([
|
||||||
@ -1608,17 +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, {})
|
hy.importer.hy_eval(new_expression, {})
|
||||||
|
|
||||||
return self.compile(new_expression)
|
return self.compile(new_expression)
|
||||||
|
|
||||||
@builds(HyInteger)
|
@builds(HyInteger)
|
||||||
|
@ -4,7 +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 *
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user