Adding in more better voodoo.
This commit is contained in:
parent
f36fa0f6de
commit
8994f4fbb9
@ -23,6 +23,7 @@ def _add_native_methods(mod):
|
||||
|
||||
eval(shim.__code__, mod.__dict__)
|
||||
|
||||
|
||||
def forge_module(name, fpath, forest):
|
||||
mod = imp.new_module(name)
|
||||
mod.__file__ = fpath
|
||||
|
@ -14,7 +14,11 @@ def _fn(obj):
|
||||
meth = args[1]
|
||||
|
||||
def _(*args, **kwargs):
|
||||
# meth validation
|
||||
for i in range(0, len(sig)):
|
||||
name = sig[i]
|
||||
value = args[i]
|
||||
obj.namespace[name] = value
|
||||
|
||||
return meth(*args, **kwargs)
|
||||
return _
|
||||
|
||||
|
9
hy/lang/symbol.py
Normal file
9
hy/lang/symbol.py
Normal file
@ -0,0 +1,9 @@
|
||||
from hy.lang.hyobj import HYObject
|
||||
|
||||
|
||||
class HYSymbol(unicode, HYObject):
|
||||
def __init__(self, string):
|
||||
self += string
|
||||
|
||||
def eval(self, *args, **kwargs):
|
||||
return self.namespace[self]
|
@ -1,6 +1,7 @@
|
||||
from hy.lang.expression import HYExpression
|
||||
from hy.lex.errors import LexException
|
||||
from hy.lang.string import HYString
|
||||
from hy.lang.symbol import HYSymbol
|
||||
from hy.lex.machine import Machine
|
||||
from hy.lang.list import HYList
|
||||
|
||||
@ -56,13 +57,13 @@ class Expression(State):
|
||||
|
||||
def exit(self):
|
||||
if self.bulk:
|
||||
self.nodes.append(HYString(self.bulk))
|
||||
self.nodes.append(HYSymbol(self.bulk))
|
||||
|
||||
self.machine.nodes.append(self.nodes)
|
||||
|
||||
def commit(self):
|
||||
if self.bulk.strip() != "":
|
||||
self.nodes.append(HYString(self.bulk))
|
||||
self.nodes.append(HYSymbol(self.bulk))
|
||||
self.bulk = ""
|
||||
|
||||
def p(self, x):
|
||||
@ -82,12 +83,12 @@ class List(State):
|
||||
|
||||
def exit(self):
|
||||
if self.bulk:
|
||||
self.nodes.append(HYString(self.bulk))
|
||||
self.nodes.append(HYSymbol(self.bulk))
|
||||
self.machine.nodes.append(self.nodes)
|
||||
|
||||
def commit(self):
|
||||
if self.bulk.strip() != "":
|
||||
self.nodes.append(HYString(self.bulk))
|
||||
self.nodes.append(HYSymbol(self.bulk))
|
||||
self.bulk = ""
|
||||
|
||||
def p(self, x):
|
||||
|
Loading…
x
Reference in New Issue
Block a user