Tooling around with some things.
This commit is contained in:
parent
73e43d71b7
commit
c2b87efc6c
0
hy/emitters/__init__.py
Normal file
0
hy/emitters/__init__.py
Normal file
@ -1,5 +1,17 @@
|
|||||||
#
|
#
|
||||||
|
import ast
|
||||||
|
|
||||||
|
|
||||||
|
def emit_node(node):
|
||||||
|
print type(node)
|
||||||
|
body = []
|
||||||
|
for sn in node.get_children():
|
||||||
|
body.append(emit_node(sn))
|
||||||
|
print body
|
||||||
|
|
||||||
|
|
||||||
def emit(tree):
|
def emit(tree):
|
||||||
pass
|
ret = []
|
||||||
|
for node in tree:
|
||||||
|
ret.append(emit_node(node))
|
||||||
|
return ret
|
||||||
|
@ -2,6 +2,12 @@ class HYExpression(list):
|
|||||||
def __init__(self, nodes):
|
def __init__(self, nodes):
|
||||||
self += nodes
|
self += nodes
|
||||||
|
|
||||||
|
def get_children(self):
|
||||||
|
ret = []
|
||||||
|
for node in self.get_invocation()['args']:
|
||||||
|
ret.append(node)
|
||||||
|
return ret
|
||||||
|
|
||||||
def get_invocation(self):
|
def get_invocation(self):
|
||||||
fn = self[0] if len(self) > 0 else ""
|
fn = self[0] if len(self) > 0 else ""
|
||||||
args = self[1:] if len(self) > 1 else []
|
args = self[1:] if len(self) > 1 else []
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
class HYList(list):
|
class HYList(list):
|
||||||
def __init__(self, nodes):
|
def __init__(self, nodes):
|
||||||
self += nodes
|
self += nodes
|
||||||
|
|
||||||
|
def get_children(self):
|
||||||
|
return []
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
class HYString(str):
|
class HYString(unicode):
|
||||||
def __init__(self, string):
|
def __init__(self, string):
|
||||||
self = string # NOQA
|
self += string
|
||||||
|
|
||||||
|
def get_children(self):
|
||||||
|
return []
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from hy.lang.expression import HYExpression
|
from hy.lang.expression import HYExpression
|
||||||
from hy.lex.errors import LexException
|
from hy.lex.errors import LexException
|
||||||
|
from hy.lang.string import HYString
|
||||||
from hy.lex.machine import Machine
|
from hy.lex.machine import Machine
|
||||||
from hy.lang.list import HYList
|
from hy.lang.list import HYList
|
||||||
|
|
||||||
@ -107,7 +108,7 @@ class String(State):
|
|||||||
self.esc = False
|
self.esc = False
|
||||||
|
|
||||||
def exit(self):
|
def exit(self):
|
||||||
self.machine.nodes.append(self.buf)
|
self.machine.nodes.append(HYString(self.buf))
|
||||||
|
|
||||||
def p(self, x):
|
def p(self, x):
|
||||||
if x == "\\":
|
if x == "\\":
|
||||||
|
Loading…
Reference in New Issue
Block a user