Merge branch 'master' of github.com:paultag/hymenoptera

This commit is contained in:
Paul Tagliamonte 2012-12-22 00:18:50 -05:00
commit 9612601fce
3 changed files with 35 additions and 2 deletions

21
hy/compiler/ast27.py Normal file
View File

@ -0,0 +1,21 @@
# output ast for cpython 2.7
from hy.lang.builtins import builtins
# check compiler/modfaker for other crap
offset = 0
def _new_fn_name():
global offset
offset += 1
return "_hy_fn_%s" % (offset)
# body=[Print(dest=None,
# values=[BinOp(left=Num(n=1), op=Add(), right=Num(n=1))],
# nl=True)]
# body=[Expr(value=BinOp(left=Num(n=1), op=Add(), right=Num(n=1)))]
def forge_ast(name, forest):
for tree in forest:
print tree

View File

@ -1,6 +1,7 @@
#
import sys
from hy.lang.internals import HYNamespaceCOW
from hy.lang.string import HYString
def _define(obj, lns):
@ -17,10 +18,15 @@ def _loop(obj, lns):
arg.eval(lns.clone())
def _fn(obj, lns):
def _fn(obj, lns, name=None):
fd = obj.get_invocation()
args = fd['args']
sig = args[0]
docstring = None
if isinstance(args[1], HYString):
docstring = args.pop(1)
meth = args[1]
def _(*args, **kwargs):
@ -32,6 +38,12 @@ def _fn(obj, lns):
ret = meth.eval(l, *args, **kwargs)
return ret
_.__name__ = "hyfn"
if name:
_.__name__ = name
_.__doc__ = docstring
return _

View File

@ -18,7 +18,7 @@ class HYExpression(HYObject, list):
return {
"function": fn,
"args": args
"args": args,
}
def peek(self):