diff --git a/src/function/builtin/BackquoteEvaluator.java b/src/function/builtin/BackquoteEvaluator.java index c882423..e62738c 100644 --- a/src/function/builtin/BackquoteEvaluator.java +++ b/src/function/builtin/BackquoteEvaluator.java @@ -57,6 +57,8 @@ class BackquoteEvaluator { throw new AtSignNotInCommaException(); else if (expression.isComma()) resolveCommaExpression(expression); + else if (expression.isList()) + resolveListExpression(expression); else addResolvedExpression(expression); } @@ -122,6 +124,11 @@ class BackquoteEvaluator { leader = (Cons) leader.getRest(); } + private void resolveListExpression(SExpression expression) { + BackquoteEvaluator evaluator = new BackquoteEvaluator(new BackquoteExpression(expression)); + addResolvedExpression(evaluator.evaluate()); + } + private static class CommaEvaluationResult { private SExpression result; diff --git a/test/function/builtin/EVALTester.java b/test/function/builtin/EVALTester.java index 2b51bd4..ec6b9ff 100644 --- a/test/function/builtin/EVALTester.java +++ b/test/function/builtin/EVALTester.java @@ -148,4 +148,18 @@ public class EVALTester { assertIsErrorWithMessage(new UnmatchedAtSignException()); } + @Test + public void evalQuoteInNestedList() { + String input = "(let ((g 27)) `((,g)))"; + + assertSExpressionsMatch(parseString("((27))"), evaluateString(input)); + } + + @Test + public void evalAtSignInNestedList() { + String input = "(let ((g '(1 2 3))) `((,@g)))"; + + assertSExpressionsMatch(parseString("((1 2 3))"), evaluateString(input)); + } + }