From ccfcefe207beedc56c4196e1648bb5b0d83fd802 Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Sat, 9 Mar 2013 16:42:07 -0500 Subject: [PATCH] adjust calling bits to allow ((foo)) --- hy/compiler.py | 7 ++++--- hy/macros.py | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 9989ec4..8a59ba4 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -214,10 +214,11 @@ class HyASTCompiler(object): @builds(HyExpression) def compile_expression(self, expression): fn = expression[0] - if fn in _compile_table: - return _compile_table[fn](self, expression) + if isinstance(fn, HyString): + if fn in _compile_table: + return _compile_table[fn](self, expression) - return ast.Call(func=self.compile_symbol(fn), + return ast.Call(func=self.compile(fn), args=[self.compile(x) for x in expression[1:]], keywords=[], starargs=None, diff --git a/hy/macros.py b/hy/macros.py index e037dfc..fa43d18 100644 --- a/hy/macros.py +++ b/hy/macros.py @@ -19,6 +19,7 @@ # DEALINGS IN THE SOFTWARE. from hy.models.expression import HyExpression +from hy.models.string import HyString from hy.models.list import HyList _hy_macros = {} @@ -36,11 +37,12 @@ def process(tree): fn = tree[0] ntree = HyExpression([fn] + [process(x) for x in tree[1:]]) - if fn in _hy_macros: - m = _hy_macros[fn] - obj = m(ntree) - obj.replace(tree) - return obj + if isinstance(fn, HyString): + if fn in _hy_macros: + m = _hy_macros[fn] + obj = m(ntree) + obj.replace(tree) + return obj ntree.replace(tree) return ntree