diff --git a/src/function/UserDefinedFunction.java b/src/function/UserDefinedFunction.java index 648b68b..2ee45da 100644 --- a/src/function/UserDefinedFunction.java +++ b/src/function/UserDefinedFunction.java @@ -1,8 +1,9 @@ package function; +import static function.builtin.EVAL.eval; + import java.util.ArrayList; -import function.builtin.EVAL; import sexpression.*; import table.*; @@ -40,7 +41,7 @@ public class UserDefinedFunction extends LispFunction { SExpression lastEvaluation = Nil.getInstance(); for (Cons expression = body; expression.consp(); expression = (Cons) expression.getCdr()) - lastEvaluation = EVAL.eval(expression.getCar()); + lastEvaluation = eval(expression.getCar()); executionContext.setScope(callingScope); releaseParameterValues(); diff --git a/src/function/builtin/LOAD.java b/src/function/builtin/LOAD.java index d161b15..c21c9da 100644 --- a/src/function/builtin/LOAD.java +++ b/src/function/builtin/LOAD.java @@ -1,5 +1,7 @@ package function.builtin; +import static function.builtin.EVAL.eval; + import java.io.*; import java.text.MessageFormat; @@ -59,7 +61,7 @@ public class LOAD extends LispFunction { private boolean isSuccessfulEvaluation(LispParser parser) { while (!parser.isEof()) { try { - EVAL.eval(parser.getNextSExpression()); + eval(parser.getNextSExpression()); } catch (LispException e) { errorManager.handle(e); return false; diff --git a/src/function/builtin/special/AND.java b/src/function/builtin/special/AND.java index 55de758..b78d1bf 100644 --- a/src/function/builtin/special/AND.java +++ b/src/function/builtin/special/AND.java @@ -1,7 +1,8 @@ package function.builtin.special; +import static function.builtin.EVAL.eval; + import function.*; -import function.builtin.EVAL; import sexpression.*; public class AND extends LispFunction { @@ -19,7 +20,7 @@ public class AND extends LispFunction { } private SExpression callTailRecursive(Cons argumentList, SExpression lastValue) { - SExpression currentValue = EVAL.eval(argumentList.getCar()); + SExpression currentValue = eval(argumentList.getCar()); Cons remainingValues = (Cons) argumentList.getCdr(); if (argumentList.nullp()) diff --git a/src/function/builtin/special/COND.java b/src/function/builtin/special/COND.java index 54cdcba..acb1ae9 100644 --- a/src/function/builtin/special/COND.java +++ b/src/function/builtin/special/COND.java @@ -1,7 +1,8 @@ package function.builtin.special; +import static function.builtin.EVAL.eval; + import function.*; -import function.builtin.EVAL; import sexpression.*; public class COND extends LispFunction { @@ -26,7 +27,7 @@ public class COND extends LispFunction { Cons clause = (Cons) argumentList.getCar(); Cons remainingClauses = (Cons) argumentList.getCdr(); - SExpression test = EVAL.eval(clause.getCar()); + SExpression test = eval(clause.getCar()); if (isTestSuccessful(test)) return evaluateResult(clause, test); @@ -42,7 +43,7 @@ public class COND extends LispFunction { SExpression lastResultValue = test; for (SExpression result = clause.getCdr(); result.consp(); result = advanceCons(result)) - lastResultValue = EVAL.eval(getCar(result)); + lastResultValue = eval(getCar(result)); return lastResultValue; } diff --git a/src/function/builtin/special/LET.java b/src/function/builtin/special/LET.java index ef4f9b4..ff4d787 100644 --- a/src/function/builtin/special/LET.java +++ b/src/function/builtin/special/LET.java @@ -1,7 +1,8 @@ package function.builtin.special; +import static function.builtin.EVAL.eval; + import function.*; -import function.builtin.EVAL; import sexpression.*; import table.*; @@ -65,14 +66,14 @@ public class LET extends LispFunction { SExpression symbol = symbolValuePair.getCar(); SExpression value = restOfPair.getCar(); - scope.put(symbol.toString(), EVAL.eval(value)); + scope.put(symbol.toString(), eval(value)); } private SExpression evaluateBody(Cons body) { SExpression lastEvaluation = Nil.getInstance(); for (; body.consp(); body = (Cons) body.getCdr()) - lastEvaluation = EVAL.eval(body.getCar()); + lastEvaluation = eval(body.getCar()); return lastEvaluation; } diff --git a/src/function/builtin/special/OR.java b/src/function/builtin/special/OR.java index d6d971d..b7cef4c 100644 --- a/src/function/builtin/special/OR.java +++ b/src/function/builtin/special/OR.java @@ -1,7 +1,8 @@ package function.builtin.special; +import static function.builtin.EVAL.eval; + import function.*; -import function.builtin.EVAL; import sexpression.*; public class OR extends LispFunction { @@ -19,7 +20,7 @@ public class OR extends LispFunction { } private SExpression callTailRecursive(Cons argumentList) { - SExpression currentValue = EVAL.eval(argumentList.getCar()); + SExpression currentValue = eval(argumentList.getCar()); Cons remainingValues = (Cons) argumentList.getCdr(); if (remainingValues.nullp() || !currentValue.nullp()) diff --git a/src/function/builtin/special/SETF.java b/src/function/builtin/special/SETF.java index b9d5d25..1120876 100644 --- a/src/function/builtin/special/SETF.java +++ b/src/function/builtin/special/SETF.java @@ -1,7 +1,8 @@ package function.builtin.special; +import static function.builtin.EVAL.eval; + import function.*; -import function.builtin.EVAL; import sexpression.*; import table.*; @@ -22,7 +23,7 @@ public class SETF extends LispFunction { Cons cdr = (Cons) argumentList.getCdr(); SExpression symbol = argumentList.getCar(); - SExpression value = EVAL.eval(cdr.getCar()); + SExpression value = eval(cdr.getCar()); SymbolTable table = findScopeOfSymbol(symbol); table.put(symbol.toString(), value); diff --git a/src/interpreter/LispInterpreter.java b/src/interpreter/LispInterpreter.java index f3f0121..3462ec9 100644 --- a/src/interpreter/LispInterpreter.java +++ b/src/interpreter/LispInterpreter.java @@ -1,8 +1,9 @@ package interpreter; +import static function.builtin.EVAL.eval; + import environment.RuntimeEnvironment; import error.*; -import function.builtin.EVAL; import parser.LispParser; import sexpression.SExpression; @@ -42,7 +43,7 @@ public class LispInterpreter { private void printValueOfNextSExpressionWithException() { SExpression sExpression = parser.getNextSExpression(); - String result = environment.decorateValueOutput(String.valueOf(EVAL.eval(sExpression))); + String result = environment.decorateValueOutput(String.valueOf(eval(sExpression))); erasePrompt(); environment.getOutput().println(result); diff --git a/test/testutil/TestUtilities.java b/test/testutil/TestUtilities.java index 4e88dd3..af14fac 100644 --- a/test/testutil/TestUtilities.java +++ b/test/testutil/TestUtilities.java @@ -1,10 +1,10 @@ package testutil; +import static function.builtin.EVAL.eval; import static org.junit.Assert.assertEquals; import java.io.*; -import function.builtin.EVAL; import parser.LispParser; import sexpression.SExpression; @@ -24,7 +24,7 @@ public final class TestUtilities { } public static SExpression evaluateString(String input) { - return EVAL.eval(parseString(input)); + return eval(parseString(input)); } public static SExpression parseString(String input) {