Adding in some prototype bits for quoted forms.
This commit is contained in:
parent
efb8addc6f
commit
f27378e57a
@ -160,6 +160,22 @@ class HyASTCompiler(object):
|
||||
def compile_raw_list(self, entries):
|
||||
return [self.compile(x) for x in entries]
|
||||
|
||||
def _render_quoted_form(self, form):
|
||||
name = form.__class__.__name__
|
||||
if isinstance(form, HyList):
|
||||
return HyExpression(
|
||||
[HySymbol(name),
|
||||
HyList([self._render_quoted_form(x) for x in form])]
|
||||
).replace(form)
|
||||
elif isinstance(form, HySymbol):
|
||||
return HyExpression([HySymbol(name), HyString(form)]).replace(form)
|
||||
return HyExpression([HySymbol(name), form]).replace(form)
|
||||
|
||||
@builds("quote")
|
||||
@checkargs(min=1, max=2)
|
||||
def compile_quote(self, entries):
|
||||
return self.compile(self._render_quoted_form(entries[1]))
|
||||
|
||||
@builds("do")
|
||||
@builds("progn")
|
||||
def compile_do_expression(self, expr):
|
||||
|
@ -34,3 +34,5 @@ class HyObject(object):
|
||||
setattr(self, attr, getattr(other, attr))
|
||||
else:
|
||||
raise TypeError("Can't replace a non Hy object with a Hy object")
|
||||
|
||||
return self
|
||||
|
@ -31,6 +31,7 @@ class HyList(HyObject, list):
|
||||
x.replace(other)
|
||||
|
||||
HyObject.replace(self, other)
|
||||
return self
|
||||
|
||||
def __repr__(self):
|
||||
return "[%s]" % (" ".join([str(x) for x in self]))
|
||||
|
Loading…
Reference in New Issue
Block a user