Fix nested comma handling in a backquote
This commit is contained in:
parent
e89a6f2dde
commit
c2d722d5ab
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue