diff --git a/pom.xml b/pom.xml index dbab89a..d473dad 100644 --- a/pom.xml +++ b/pom.xml @@ -16,9 +16,8 @@ - - - + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin diff --git a/src/main/java/table/SymbolTable.java b/src/main/java/table/SymbolTable.java deleted file mode 100644 index 8e16395..0000000 --- a/src/main/java/table/SymbolTable.java +++ /dev/null @@ -1,67 +0,0 @@ -package table; - -import sexpression.Cons; -import sexpression.SExpression; -import sexpression.Symbol; -import table.ExecutionContext.NullSymbolTable; - -import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeMap; - -import static function.builtin.cons.APPEND.append; -import static function.builtin.cons.LIST.makeList; -import static sexpression.Nil.NIL; - -public class SymbolTable { - - private HashMap table; - private SymbolTable parent; - - public SymbolTable() { - this(NullSymbolTable.INSTANCE); - } - - public SymbolTable(SymbolTable parent) { - this.table = new HashMap(); - this.parent = parent; - } - - public boolean contains(String symbolName) { - return table.containsKey(symbolName); - } - - public SExpression get(String symbolName) { - return table.get(symbolName); - } - - public void put(String symbolName, SExpression value) { - table.put(symbolName, value); - } - - public SymbolTable getParent() { - return parent; - } - - public boolean isGlobal() { - return parent == NullSymbolTable.INSTANCE; - } - - public Cons toList() { - Cons context = NIL; - - for (Entry binding : getSortedBindings()) - context = append(context, makeList(makeSymbolValuePair(binding))); - - return context; - } - - private Set> getSortedBindings() { - return new TreeMap<>(table).entrySet(); - } - - private Cons makeSymbolValuePair(Entry binding) { - return new Cons(new Symbol(binding.getKey()), makeList(binding.getValue())); - } -} diff --git a/src/main/java/application/LispMain.java b/src/main/kotlin/application/LispMain.java similarity index 100% rename from src/main/java/application/LispMain.java rename to src/main/kotlin/application/LispMain.java diff --git a/src/main/java/environment/RuntimeEnvironment.java b/src/main/kotlin/environment/RuntimeEnvironment.java similarity index 100% rename from src/main/java/environment/RuntimeEnvironment.java rename to src/main/kotlin/environment/RuntimeEnvironment.java diff --git a/src/main/java/error/CriticalLineColumnException.kt b/src/main/kotlin/error/CriticalLineColumnException.kt similarity index 100% rename from src/main/java/error/CriticalLineColumnException.kt rename to src/main/kotlin/error/CriticalLineColumnException.kt diff --git a/src/main/java/error/CriticalLispException.kt b/src/main/kotlin/error/CriticalLispException.kt similarity index 100% rename from src/main/java/error/CriticalLispException.kt rename to src/main/kotlin/error/CriticalLispException.kt diff --git a/src/main/java/error/ErrorManager.kt b/src/main/kotlin/error/ErrorManager.kt similarity index 100% rename from src/main/java/error/ErrorManager.kt rename to src/main/kotlin/error/ErrorManager.kt diff --git a/src/main/java/error/LineColumnException.kt b/src/main/kotlin/error/LineColumnException.kt similarity index 100% rename from src/main/java/error/LineColumnException.kt rename to src/main/kotlin/error/LineColumnException.kt diff --git a/src/main/java/error/LispException.kt b/src/main/kotlin/error/LispException.kt similarity index 100% rename from src/main/java/error/LispException.kt rename to src/main/kotlin/error/LispException.kt diff --git a/src/main/java/error/LispWarning.kt b/src/main/kotlin/error/LispWarning.kt similarity index 100% rename from src/main/java/error/LispWarning.kt rename to src/main/kotlin/error/LispWarning.kt diff --git a/src/main/java/error/Severity.kt b/src/main/kotlin/error/Severity.kt similarity index 100% rename from src/main/java/error/Severity.kt rename to src/main/kotlin/error/Severity.kt diff --git a/src/main/java/file/FilePosition.java b/src/main/kotlin/file/FilePosition.java similarity index 100% rename from src/main/java/file/FilePosition.java rename to src/main/kotlin/file/FilePosition.java diff --git a/src/main/java/file/FilePositionTracker.java b/src/main/kotlin/file/FilePositionTracker.java similarity index 100% rename from src/main/java/file/FilePositionTracker.java rename to src/main/kotlin/file/FilePositionTracker.java diff --git a/src/main/java/function/ArgumentValidator.java b/src/main/kotlin/function/ArgumentValidator.java similarity index 100% rename from src/main/java/function/ArgumentValidator.java rename to src/main/kotlin/function/ArgumentValidator.java diff --git a/src/main/java/function/FunctionNames.java b/src/main/kotlin/function/FunctionNames.java similarity index 100% rename from src/main/java/function/FunctionNames.java rename to src/main/kotlin/function/FunctionNames.java diff --git a/src/main/java/function/LispFunction.java b/src/main/kotlin/function/LispFunction.java similarity index 100% rename from src/main/java/function/LispFunction.java rename to src/main/kotlin/function/LispFunction.java diff --git a/src/main/java/function/LispSpecialFunction.java b/src/main/kotlin/function/LispSpecialFunction.java similarity index 100% rename from src/main/java/function/LispSpecialFunction.java rename to src/main/kotlin/function/LispSpecialFunction.java diff --git a/src/main/java/function/UserDefinedFunction.java b/src/main/kotlin/function/UserDefinedFunction.java similarity index 97% rename from src/main/java/function/UserDefinedFunction.java rename to src/main/kotlin/function/UserDefinedFunction.java index bb481c6..cb5bcae 100644 --- a/src/main/java/function/UserDefinedFunction.java +++ b/src/main/kotlin/function/UserDefinedFunction.java @@ -125,12 +125,12 @@ public class UserDefinedFunction extends LispFunction { for (String parameter : formalParameters) { SExpression currentArg = argumentList.getFirst(); - executionScope.put(parameter, currentArg); + executionScope.set(parameter, currentArg); argumentList = (Cons) argumentList.getRest(); } if (isKeywordRestPresent) - executionScope.put(keywordRestParameter, argumentList); + executionScope.set(keywordRestParameter, argumentList); return executionScope; } diff --git a/src/main/java/function/UserDefinedMacro.java b/src/main/kotlin/function/UserDefinedMacro.java similarity index 100% rename from src/main/java/function/UserDefinedMacro.java rename to src/main/kotlin/function/UserDefinedMacro.java diff --git a/src/main/java/function/UserDefinedSpecialFunction.java b/src/main/kotlin/function/UserDefinedSpecialFunction.java similarity index 100% rename from src/main/java/function/UserDefinedSpecialFunction.java rename to src/main/kotlin/function/UserDefinedSpecialFunction.java diff --git a/src/main/java/function/builtin/APPLY.java b/src/main/kotlin/function/builtin/APPLY.java similarity index 100% rename from src/main/java/function/builtin/APPLY.java rename to src/main/kotlin/function/builtin/APPLY.java diff --git a/src/main/java/function/builtin/BackquoteEvaluator.java b/src/main/kotlin/function/builtin/BackquoteEvaluator.java similarity index 100% rename from src/main/java/function/builtin/BackquoteEvaluator.java rename to src/main/kotlin/function/builtin/BackquoteEvaluator.java diff --git a/src/main/java/function/builtin/EVAL.java b/src/main/kotlin/function/builtin/EVAL.java similarity index 100% rename from src/main/java/function/builtin/EVAL.java rename to src/main/kotlin/function/builtin/EVAL.java diff --git a/src/main/java/function/builtin/EXIT.java b/src/main/kotlin/function/builtin/EXIT.java similarity index 100% rename from src/main/java/function/builtin/EXIT.java rename to src/main/kotlin/function/builtin/EXIT.java diff --git a/src/main/java/function/builtin/FUNCALL.java b/src/main/kotlin/function/builtin/FUNCALL.java similarity index 100% rename from src/main/java/function/builtin/FUNCALL.java rename to src/main/kotlin/function/builtin/FUNCALL.java diff --git a/src/main/java/function/builtin/FUSE.java b/src/main/kotlin/function/builtin/FUSE.java similarity index 100% rename from src/main/java/function/builtin/FUSE.java rename to src/main/kotlin/function/builtin/FUSE.java diff --git a/src/main/java/function/builtin/GENSYM.java b/src/main/kotlin/function/builtin/GENSYM.java similarity index 100% rename from src/main/java/function/builtin/GENSYM.java rename to src/main/kotlin/function/builtin/GENSYM.java diff --git a/src/main/java/function/builtin/LOAD.java b/src/main/kotlin/function/builtin/LOAD.java similarity index 100% rename from src/main/java/function/builtin/LOAD.java rename to src/main/kotlin/function/builtin/LOAD.java diff --git a/src/main/java/function/builtin/PRINT.java b/src/main/kotlin/function/builtin/PRINT.java similarity index 100% rename from src/main/java/function/builtin/PRINT.java rename to src/main/kotlin/function/builtin/PRINT.java diff --git a/src/main/java/function/builtin/SET.java b/src/main/kotlin/function/builtin/SET.java similarity index 97% rename from src/main/java/function/builtin/SET.java rename to src/main/kotlin/function/builtin/SET.java index 1810449..84a8fd4 100644 --- a/src/main/java/function/builtin/SET.java +++ b/src/main/kotlin/function/builtin/SET.java @@ -37,7 +37,7 @@ public class SET extends LispFunction { SExpression value = rest.getFirst(); SymbolTable table = findScopeOfSymbol(symbol); - table.put(symbol.toString(), value); + table.set(symbol.toString(), value); return value; } diff --git a/src/main/java/function/builtin/SYMBOLS.java b/src/main/kotlin/function/builtin/SYMBOLS.java similarity index 100% rename from src/main/java/function/builtin/SYMBOLS.java rename to src/main/kotlin/function/builtin/SYMBOLS.java diff --git a/src/main/java/function/builtin/SYMBOL_FUNCTION.java b/src/main/kotlin/function/builtin/SYMBOL_FUNCTION.java similarity index 100% rename from src/main/java/function/builtin/SYMBOL_FUNCTION.java rename to src/main/kotlin/function/builtin/SYMBOL_FUNCTION.java diff --git a/src/main/java/function/builtin/cons/APPEND.java b/src/main/kotlin/function/builtin/cons/APPEND.java similarity index 100% rename from src/main/java/function/builtin/cons/APPEND.java rename to src/main/kotlin/function/builtin/cons/APPEND.java diff --git a/src/main/java/function/builtin/cons/CONS.java b/src/main/kotlin/function/builtin/cons/CONS.java similarity index 100% rename from src/main/java/function/builtin/cons/CONS.java rename to src/main/kotlin/function/builtin/cons/CONS.java diff --git a/src/main/java/function/builtin/cons/FIRST.java b/src/main/kotlin/function/builtin/cons/FIRST.java similarity index 100% rename from src/main/java/function/builtin/cons/FIRST.java rename to src/main/kotlin/function/builtin/cons/FIRST.java diff --git a/src/main/java/function/builtin/cons/LENGTH.java b/src/main/kotlin/function/builtin/cons/LENGTH.java similarity index 100% rename from src/main/java/function/builtin/cons/LENGTH.java rename to src/main/kotlin/function/builtin/cons/LENGTH.java diff --git a/src/main/java/function/builtin/cons/LIST.java b/src/main/kotlin/function/builtin/cons/LIST.java similarity index 100% rename from src/main/java/function/builtin/cons/LIST.java rename to src/main/kotlin/function/builtin/cons/LIST.java diff --git a/src/main/java/function/builtin/cons/REST.java b/src/main/kotlin/function/builtin/cons/REST.java similarity index 100% rename from src/main/java/function/builtin/cons/REST.java rename to src/main/kotlin/function/builtin/cons/REST.java diff --git a/src/main/java/function/builtin/math/DIVIDE.java b/src/main/kotlin/function/builtin/math/DIVIDE.java similarity index 100% rename from src/main/java/function/builtin/math/DIVIDE.java rename to src/main/kotlin/function/builtin/math/DIVIDE.java diff --git a/src/main/java/function/builtin/math/MINUS.java b/src/main/kotlin/function/builtin/math/MINUS.java similarity index 100% rename from src/main/java/function/builtin/math/MINUS.java rename to src/main/kotlin/function/builtin/math/MINUS.java diff --git a/src/main/java/function/builtin/math/MODULO.java b/src/main/kotlin/function/builtin/math/MODULO.java similarity index 100% rename from src/main/java/function/builtin/math/MODULO.java rename to src/main/kotlin/function/builtin/math/MODULO.java diff --git a/src/main/java/function/builtin/math/MULTIPLY.java b/src/main/kotlin/function/builtin/math/MULTIPLY.java similarity index 100% rename from src/main/java/function/builtin/math/MULTIPLY.java rename to src/main/kotlin/function/builtin/math/MULTIPLY.java diff --git a/src/main/java/function/builtin/math/MathFunction.java b/src/main/kotlin/function/builtin/math/MathFunction.java similarity index 100% rename from src/main/java/function/builtin/math/MathFunction.java rename to src/main/kotlin/function/builtin/math/MathFunction.java diff --git a/src/main/java/function/builtin/math/PLUS.java b/src/main/kotlin/function/builtin/math/PLUS.java similarity index 100% rename from src/main/java/function/builtin/math/PLUS.java rename to src/main/kotlin/function/builtin/math/PLUS.java diff --git a/src/main/java/function/builtin/math/REMAINDER.java b/src/main/kotlin/function/builtin/math/REMAINDER.java similarity index 100% rename from src/main/java/function/builtin/math/REMAINDER.java rename to src/main/kotlin/function/builtin/math/REMAINDER.java diff --git a/src/main/java/function/builtin/predicate/ATOM.java b/src/main/kotlin/function/builtin/predicate/ATOM.java similarity index 100% rename from src/main/java/function/builtin/predicate/ATOM.java rename to src/main/kotlin/function/builtin/predicate/ATOM.java diff --git a/src/main/java/function/builtin/predicate/EQ.java b/src/main/kotlin/function/builtin/predicate/EQ.java similarity index 100% rename from src/main/java/function/builtin/predicate/EQ.java rename to src/main/kotlin/function/builtin/predicate/EQ.java diff --git a/src/main/java/function/builtin/predicate/EQUAL.java b/src/main/kotlin/function/builtin/predicate/EQUAL.java similarity index 100% rename from src/main/java/function/builtin/predicate/EQUAL.java rename to src/main/kotlin/function/builtin/predicate/EQUAL.java diff --git a/src/main/java/function/builtin/predicate/GENSYM_EQUAL.java b/src/main/kotlin/function/builtin/predicate/GENSYM_EQUAL.java similarity index 100% rename from src/main/java/function/builtin/predicate/GENSYM_EQUAL.java rename to src/main/kotlin/function/builtin/predicate/GENSYM_EQUAL.java diff --git a/src/main/java/function/builtin/predicate/LISTP.java b/src/main/kotlin/function/builtin/predicate/LISTP.java similarity index 100% rename from src/main/java/function/builtin/predicate/LISTP.java rename to src/main/kotlin/function/builtin/predicate/LISTP.java diff --git a/src/main/java/function/builtin/predicate/NULL.java b/src/main/kotlin/function/builtin/predicate/NULL.java similarity index 100% rename from src/main/java/function/builtin/predicate/NULL.java rename to src/main/kotlin/function/builtin/predicate/NULL.java diff --git a/src/main/java/function/builtin/predicate/NUMERIC_EQUAL.java b/src/main/kotlin/function/builtin/predicate/NUMERIC_EQUAL.java similarity index 100% rename from src/main/java/function/builtin/predicate/NUMERIC_EQUAL.java rename to src/main/kotlin/function/builtin/predicate/NUMERIC_EQUAL.java diff --git a/src/main/java/function/builtin/predicate/NUMERIC_GREATER.java b/src/main/kotlin/function/builtin/predicate/NUMERIC_GREATER.java similarity index 100% rename from src/main/java/function/builtin/predicate/NUMERIC_GREATER.java rename to src/main/kotlin/function/builtin/predicate/NUMERIC_GREATER.java diff --git a/src/main/java/function/builtin/predicate/NUMERIC_LESS.java b/src/main/kotlin/function/builtin/predicate/NUMERIC_LESS.java similarity index 100% rename from src/main/java/function/builtin/predicate/NUMERIC_LESS.java rename to src/main/kotlin/function/builtin/predicate/NUMERIC_LESS.java diff --git a/src/main/java/function/builtin/special/AND.java b/src/main/kotlin/function/builtin/special/AND.java similarity index 100% rename from src/main/java/function/builtin/special/AND.java rename to src/main/kotlin/function/builtin/special/AND.java diff --git a/src/main/java/function/builtin/special/CASE.java b/src/main/kotlin/function/builtin/special/CASE.java similarity index 100% rename from src/main/java/function/builtin/special/CASE.java rename to src/main/kotlin/function/builtin/special/CASE.java diff --git a/src/main/java/function/builtin/special/COND.java b/src/main/kotlin/function/builtin/special/COND.java similarity index 100% rename from src/main/java/function/builtin/special/COND.java rename to src/main/kotlin/function/builtin/special/COND.java diff --git a/src/main/java/function/builtin/special/DEFINE_SPECIAL.java b/src/main/kotlin/function/builtin/special/DEFINE_SPECIAL.java similarity index 100% rename from src/main/java/function/builtin/special/DEFINE_SPECIAL.java rename to src/main/kotlin/function/builtin/special/DEFINE_SPECIAL.java diff --git a/src/main/java/function/builtin/special/DEFMACRO.java b/src/main/kotlin/function/builtin/special/DEFMACRO.java similarity index 100% rename from src/main/java/function/builtin/special/DEFMACRO.java rename to src/main/kotlin/function/builtin/special/DEFMACRO.java diff --git a/src/main/java/function/builtin/special/DEFUN.java b/src/main/kotlin/function/builtin/special/DEFUN.java similarity index 100% rename from src/main/java/function/builtin/special/DEFUN.java rename to src/main/kotlin/function/builtin/special/DEFUN.java diff --git a/src/main/java/function/builtin/special/Define.java b/src/main/kotlin/function/builtin/special/Define.java similarity index 100% rename from src/main/java/function/builtin/special/Define.java rename to src/main/kotlin/function/builtin/special/Define.java diff --git a/src/main/java/function/builtin/special/IF.java b/src/main/kotlin/function/builtin/special/IF.java similarity index 100% rename from src/main/java/function/builtin/special/IF.java rename to src/main/kotlin/function/builtin/special/IF.java diff --git a/src/main/java/function/builtin/special/LAMBDA.kt b/src/main/kotlin/function/builtin/special/LAMBDA.kt similarity index 100% rename from src/main/java/function/builtin/special/LAMBDA.kt rename to src/main/kotlin/function/builtin/special/LAMBDA.kt diff --git a/src/main/java/function/builtin/special/LET.java b/src/main/kotlin/function/builtin/special/LET.java similarity index 98% rename from src/main/java/function/builtin/special/LET.java rename to src/main/kotlin/function/builtin/special/LET.java index 012d95a..8d594a4 100644 --- a/src/main/java/function/builtin/special/LET.java +++ b/src/main/kotlin/function/builtin/special/LET.java @@ -75,7 +75,7 @@ public class LET extends LispSpecialFunction { SExpression symbol = symbolValuePair.getFirst(); SExpression value = restOfPair.getFirst(); - scope.put(symbol.toString(), eval(value)); + scope.set(symbol.toString(), eval(value)); } private SExpression evaluateBody(Cons body) { diff --git a/src/main/java/function/builtin/special/LET_STAR.java b/src/main/kotlin/function/builtin/special/LET_STAR.java similarity index 100% rename from src/main/java/function/builtin/special/LET_STAR.java rename to src/main/kotlin/function/builtin/special/LET_STAR.java diff --git a/src/main/java/function/builtin/special/OR.java b/src/main/kotlin/function/builtin/special/OR.java similarity index 100% rename from src/main/java/function/builtin/special/OR.java rename to src/main/kotlin/function/builtin/special/OR.java diff --git a/src/main/java/function/builtin/special/PROGN.java b/src/main/kotlin/function/builtin/special/PROGN.java similarity index 100% rename from src/main/java/function/builtin/special/PROGN.java rename to src/main/kotlin/function/builtin/special/PROGN.java diff --git a/src/main/java/function/builtin/special/QUOTE.java b/src/main/kotlin/function/builtin/special/QUOTE.java similarity index 100% rename from src/main/java/function/builtin/special/QUOTE.java rename to src/main/kotlin/function/builtin/special/QUOTE.java diff --git a/src/main/java/function/builtin/special/RECUR.java b/src/main/kotlin/function/builtin/special/RECUR.java similarity index 100% rename from src/main/java/function/builtin/special/RECUR.java rename to src/main/kotlin/function/builtin/special/RECUR.java diff --git a/src/main/java/function/builtin/special/SETQ.java b/src/main/kotlin/function/builtin/special/SETQ.java similarity index 100% rename from src/main/java/function/builtin/special/SETQ.java rename to src/main/kotlin/function/builtin/special/SETQ.java diff --git a/src/main/java/interpreter/FileLispInterpreter.java b/src/main/kotlin/interpreter/FileLispInterpreter.java similarity index 100% rename from src/main/java/interpreter/FileLispInterpreter.java rename to src/main/kotlin/interpreter/FileLispInterpreter.java diff --git a/src/main/java/interpreter/InteractiveLispInterpreter.java b/src/main/kotlin/interpreter/InteractiveLispInterpreter.java similarity index 100% rename from src/main/java/interpreter/InteractiveLispInterpreter.java rename to src/main/kotlin/interpreter/InteractiveLispInterpreter.java diff --git a/src/main/java/interpreter/LispInterpreter.java b/src/main/kotlin/interpreter/LispInterpreter.java similarity index 100% rename from src/main/java/interpreter/LispInterpreter.java rename to src/main/kotlin/interpreter/LispInterpreter.java diff --git a/src/main/java/interpreter/LispInterpreterBuilder.java b/src/main/kotlin/interpreter/LispInterpreterBuilder.java similarity index 100% rename from src/main/java/interpreter/LispInterpreterBuilder.java rename to src/main/kotlin/interpreter/LispInterpreterBuilder.java diff --git a/src/main/java/interpreter/LispInterpreterBuilderImpl.java b/src/main/kotlin/interpreter/LispInterpreterBuilderImpl.java similarity index 100% rename from src/main/java/interpreter/LispInterpreterBuilderImpl.java rename to src/main/kotlin/interpreter/LispInterpreterBuilderImpl.java diff --git a/src/main/java/parser/LispParser.java b/src/main/kotlin/parser/LispParser.java similarity index 100% rename from src/main/java/parser/LispParser.java rename to src/main/kotlin/parser/LispParser.java diff --git a/src/main/java/recursion/TailCall.java b/src/main/kotlin/recursion/TailCall.java similarity index 100% rename from src/main/java/recursion/TailCall.java rename to src/main/kotlin/recursion/TailCall.java diff --git a/src/main/java/recursion/TailCalls.java b/src/main/kotlin/recursion/TailCalls.java similarity index 100% rename from src/main/java/recursion/TailCalls.java rename to src/main/kotlin/recursion/TailCalls.java diff --git a/src/main/java/scanner/LispCommentRemovingInputStream.java b/src/main/kotlin/scanner/LispCommentRemovingInputStream.java similarity index 100% rename from src/main/java/scanner/LispCommentRemovingInputStream.java rename to src/main/kotlin/scanner/LispCommentRemovingInputStream.java diff --git a/src/main/java/scanner/LispInputStream.java b/src/main/kotlin/scanner/LispInputStream.java similarity index 100% rename from src/main/java/scanner/LispInputStream.java rename to src/main/kotlin/scanner/LispInputStream.java diff --git a/src/main/java/scanner/LispScanner.java b/src/main/kotlin/scanner/LispScanner.java similarity index 100% rename from src/main/java/scanner/LispScanner.java rename to src/main/kotlin/scanner/LispScanner.java diff --git a/src/main/java/sexpression/AtSignExpression.java b/src/main/kotlin/sexpression/AtSignExpression.java similarity index 100% rename from src/main/java/sexpression/AtSignExpression.java rename to src/main/kotlin/sexpression/AtSignExpression.java diff --git a/src/main/java/sexpression/Atom.java b/src/main/kotlin/sexpression/Atom.java similarity index 100% rename from src/main/java/sexpression/Atom.java rename to src/main/kotlin/sexpression/Atom.java diff --git a/src/main/java/sexpression/BackquoteExpression.java b/src/main/kotlin/sexpression/BackquoteExpression.java similarity index 100% rename from src/main/java/sexpression/BackquoteExpression.java rename to src/main/kotlin/sexpression/BackquoteExpression.java diff --git a/src/main/java/sexpression/CommaExpression.java b/src/main/kotlin/sexpression/CommaExpression.java similarity index 100% rename from src/main/java/sexpression/CommaExpression.java rename to src/main/kotlin/sexpression/CommaExpression.java diff --git a/src/main/java/sexpression/Cons.java b/src/main/kotlin/sexpression/Cons.java similarity index 100% rename from src/main/java/sexpression/Cons.java rename to src/main/kotlin/sexpression/Cons.java diff --git a/src/main/java/sexpression/DisplayName.java b/src/main/kotlin/sexpression/DisplayName.java similarity index 100% rename from src/main/java/sexpression/DisplayName.java rename to src/main/kotlin/sexpression/DisplayName.java diff --git a/src/main/java/sexpression/LambdaExpression.java b/src/main/kotlin/sexpression/LambdaExpression.java similarity index 100% rename from src/main/java/sexpression/LambdaExpression.java rename to src/main/kotlin/sexpression/LambdaExpression.java diff --git a/src/main/java/sexpression/LispNumber.java b/src/main/kotlin/sexpression/LispNumber.java similarity index 100% rename from src/main/java/sexpression/LispNumber.java rename to src/main/kotlin/sexpression/LispNumber.java diff --git a/src/main/java/sexpression/LispString.java b/src/main/kotlin/sexpression/LispString.java similarity index 100% rename from src/main/java/sexpression/LispString.java rename to src/main/kotlin/sexpression/LispString.java diff --git a/src/main/java/sexpression/Nil.java b/src/main/kotlin/sexpression/Nil.java similarity index 100% rename from src/main/java/sexpression/Nil.java rename to src/main/kotlin/sexpression/Nil.java diff --git a/src/main/java/sexpression/SExpression.java b/src/main/kotlin/sexpression/SExpression.java similarity index 100% rename from src/main/java/sexpression/SExpression.java rename to src/main/kotlin/sexpression/SExpression.java diff --git a/src/main/java/sexpression/Symbol.java b/src/main/kotlin/sexpression/Symbol.java similarity index 100% rename from src/main/java/sexpression/Symbol.java rename to src/main/kotlin/sexpression/Symbol.java diff --git a/src/main/java/stream/SafeInputStream.java b/src/main/kotlin/stream/SafeInputStream.java similarity index 100% rename from src/main/java/stream/SafeInputStream.java rename to src/main/kotlin/stream/SafeInputStream.java diff --git a/src/main/java/stream/SafeOutputStream.java b/src/main/kotlin/stream/SafeOutputStream.java similarity index 100% rename from src/main/java/stream/SafeOutputStream.java rename to src/main/kotlin/stream/SafeOutputStream.java diff --git a/src/main/java/stream/UncheckedIOException.java b/src/main/kotlin/stream/UncheckedIOException.java similarity index 100% rename from src/main/java/stream/UncheckedIOException.java rename to src/main/kotlin/stream/UncheckedIOException.java diff --git a/src/main/java/table/ExecutionContext.kt b/src/main/kotlin/table/ExecutionContext.kt similarity index 81% rename from src/main/java/table/ExecutionContext.kt rename to src/main/kotlin/table/ExecutionContext.kt index 7e6bdf0..7b12b8e 100644 --- a/src/main/java/table/ExecutionContext.kt +++ b/src/main/kotlin/table/ExecutionContext.kt @@ -2,11 +2,10 @@ package table import function.LispFunction import sexpression.Cons -import sexpression.SExpression - -import java.util.Stack - import sexpression.Nil.NIL +import sexpression.SExpression +import table.SymbolTable.NullSymbolTable +import java.util.Stack object ExecutionContext { @@ -33,17 +32,13 @@ object ExecutionContext { fun restoreGlobalScope() { while (!scope.isGlobal) - scope = scope.parent + scope = scope.parent ?: NullSymbolTable } fun lookupSymbolValue(symbolName: String): SExpression? { - var t = scope - while (t !== NullSymbolTable) { - if (t.contains(symbolName)) - return t.get(symbolName) - - t = t.parent - } + for (table in scope) + if (symbolName in table) + return table[symbolName] return null } @@ -51,11 +46,8 @@ object ExecutionContext { fun toList(): Cons { var symbols: Cons = NIL - var t = scope - while (t !== NullSymbolTable) { - symbols = Cons(t.toList(), symbols) - t = t.parent - } + for (table in scope) + symbols = Cons(table.toList(), symbols) return symbols } @@ -96,6 +88,4 @@ object ExecutionContext { isRecurInitializing = false } } - - object NullSymbolTable : SymbolTable() } diff --git a/src/main/java/table/FunctionTable.java b/src/main/kotlin/table/FunctionTable.java similarity index 100% rename from src/main/java/table/FunctionTable.java rename to src/main/kotlin/table/FunctionTable.java diff --git a/src/main/kotlin/table/SymbolTable.kt b/src/main/kotlin/table/SymbolTable.kt new file mode 100644 index 0000000..9738758 --- /dev/null +++ b/src/main/kotlin/table/SymbolTable.kt @@ -0,0 +1,61 @@ +package table + +import function.builtin.cons.APPEND.append +import function.builtin.cons.LIST.makeList +import sexpression.Cons +import sexpression.Nil.NIL +import sexpression.SExpression +import sexpression.Symbol +import java.util.HashMap +import java.util.TreeMap +import kotlin.collections.Map.Entry + +open class SymbolTable @JvmOverloads constructor(open val parent: SymbolTable? = NullSymbolTable) : Iterable { + + val isGlobal: Boolean + get() = parent === NullSymbolTable + + private val table: HashMap = HashMap() + + private val sortedBindings: Set> + get() = TreeMap(table).entries + + override fun iterator(): Iterator = SymbolTableIterator(this) + + operator fun contains(symbolName: String) = table.containsKey(symbolName) + + operator fun get(symbolName: String) = table[symbolName] + + operator fun set(symbolName: String, value: SExpression) { + table[symbolName] = value + } + + fun toList(): Cons { + var context: Cons = NIL + + for (binding in sortedBindings) + context = append(context, makeList(makeSymbolValuePair(binding))) + + return context + } + + private fun makeSymbolValuePair(binding: Entry) = + Cons(Symbol(binding.key), makeList(binding.value)) + + object NullSymbolTable : SymbolTable(null) { + override val parent: SymbolTable + get() = this + } + + private class SymbolTableIterator(private var symbolTable: SymbolTable) : AbstractIterator() { + override fun computeNext() { + when (symbolTable) { + is NullSymbolTable -> done() + else -> { + setNext(symbolTable) + symbolTable = symbolTable.parent ?: NullSymbolTable + } + } + } + } +} diff --git a/src/main/java/terminal/ControlSequence.java b/src/main/kotlin/terminal/ControlSequence.java similarity index 100% rename from src/main/java/terminal/ControlSequence.java rename to src/main/kotlin/terminal/ControlSequence.java diff --git a/src/main/java/terminal/ControlSequenceHandler.java b/src/main/kotlin/terminal/ControlSequenceHandler.java similarity index 100% rename from src/main/java/terminal/ControlSequenceHandler.java rename to src/main/kotlin/terminal/ControlSequenceHandler.java diff --git a/src/main/java/terminal/ControlSequenceLookup.java b/src/main/kotlin/terminal/ControlSequenceLookup.java similarity index 100% rename from src/main/java/terminal/ControlSequenceLookup.java rename to src/main/kotlin/terminal/ControlSequenceLookup.java diff --git a/src/main/java/terminal/LispTerminal.java b/src/main/kotlin/terminal/LispTerminal.java similarity index 100% rename from src/main/java/terminal/LispTerminal.java rename to src/main/kotlin/terminal/LispTerminal.java diff --git a/src/main/java/terminal/SelectGraphicRendition.java b/src/main/kotlin/terminal/SelectGraphicRendition.java similarity index 100% rename from src/main/java/terminal/SelectGraphicRendition.java rename to src/main/kotlin/terminal/SelectGraphicRendition.java diff --git a/src/main/java/terminal/TerminalConfiguration.java b/src/main/kotlin/terminal/TerminalConfiguration.java similarity index 100% rename from src/main/java/terminal/TerminalConfiguration.java rename to src/main/kotlin/terminal/TerminalConfiguration.java diff --git a/src/main/java/terminal/TerminalHistory.java b/src/main/kotlin/terminal/TerminalHistory.java similarity index 100% rename from src/main/java/terminal/TerminalHistory.java rename to src/main/kotlin/terminal/TerminalHistory.java diff --git a/src/main/java/token/AtSign.java b/src/main/kotlin/token/AtSign.java similarity index 100% rename from src/main/java/token/AtSign.java rename to src/main/kotlin/token/AtSign.java diff --git a/src/main/java/token/Backquote.java b/src/main/kotlin/token/Backquote.java similarity index 100% rename from src/main/java/token/Backquote.java rename to src/main/kotlin/token/Backquote.java diff --git a/src/main/java/token/Comma.java b/src/main/kotlin/token/Comma.java similarity index 100% rename from src/main/java/token/Comma.java rename to src/main/kotlin/token/Comma.java diff --git a/src/main/java/token/Eof.java b/src/main/kotlin/token/Eof.java similarity index 100% rename from src/main/java/token/Eof.java rename to src/main/kotlin/token/Eof.java diff --git a/src/main/java/token/Identifier.java b/src/main/kotlin/token/Identifier.java similarity index 100% rename from src/main/java/token/Identifier.java rename to src/main/kotlin/token/Identifier.java diff --git a/src/main/java/token/LeftParenthesis.java b/src/main/kotlin/token/LeftParenthesis.java similarity index 100% rename from src/main/java/token/LeftParenthesis.java rename to src/main/kotlin/token/LeftParenthesis.java diff --git a/src/main/java/token/Number.java b/src/main/kotlin/token/Number.java similarity index 100% rename from src/main/java/token/Number.java rename to src/main/kotlin/token/Number.java diff --git a/src/main/java/token/QuoteMark.java b/src/main/kotlin/token/QuoteMark.java similarity index 100% rename from src/main/java/token/QuoteMark.java rename to src/main/kotlin/token/QuoteMark.java diff --git a/src/main/java/token/QuotedString.java b/src/main/kotlin/token/QuotedString.java similarity index 100% rename from src/main/java/token/QuotedString.java rename to src/main/kotlin/token/QuotedString.java diff --git a/src/main/java/token/RightParenthesis.java b/src/main/kotlin/token/RightParenthesis.java similarity index 100% rename from src/main/java/token/RightParenthesis.java rename to src/main/kotlin/token/RightParenthesis.java diff --git a/src/main/java/token/Token.java b/src/main/kotlin/token/Token.java similarity index 100% rename from src/main/java/token/Token.java rename to src/main/kotlin/token/Token.java diff --git a/src/main/java/token/TokenFactory.java b/src/main/kotlin/token/TokenFactory.java similarity index 100% rename from src/main/java/token/TokenFactory.java rename to src/main/kotlin/token/TokenFactory.java diff --git a/src/main/java/token/TokenFactoryImpl.java b/src/main/kotlin/token/TokenFactoryImpl.java similarity index 100% rename from src/main/java/token/TokenFactoryImpl.java rename to src/main/kotlin/token/TokenFactoryImpl.java diff --git a/src/main/java/util/Characters.java b/src/main/kotlin/util/Characters.java similarity index 100% rename from src/main/java/util/Characters.java rename to src/main/kotlin/util/Characters.java diff --git a/src/main/java/util/Path.java b/src/main/kotlin/util/Path.java similarity index 100% rename from src/main/java/util/Path.java rename to src/main/kotlin/util/Path.java diff --git a/src/test/java/acceptance/AcceptanceTest.java b/src/test/kotlin/acceptance/AcceptanceTest.java similarity index 100% rename from src/test/java/acceptance/AcceptanceTest.java rename to src/test/kotlin/acceptance/AcceptanceTest.java diff --git a/src/test/java/acceptance/fixture/LispInterpreterFixture.java b/src/test/kotlin/acceptance/fixture/LispInterpreterFixture.java similarity index 100% rename from src/test/java/acceptance/fixture/LispInterpreterFixture.java rename to src/test/kotlin/acceptance/fixture/LispInterpreterFixture.java diff --git a/src/test/java/application/MainTest.java b/src/test/kotlin/application/MainTest.java similarity index 100% rename from src/test/java/application/MainTest.java rename to src/test/kotlin/application/MainTest.java diff --git a/src/test/java/environment/RuntimeEnvironmentTest.java b/src/test/kotlin/environment/RuntimeEnvironmentTest.java similarity index 100% rename from src/test/java/environment/RuntimeEnvironmentTest.java rename to src/test/kotlin/environment/RuntimeEnvironmentTest.java diff --git a/src/test/java/error/ErrorManagerTest.java b/src/test/kotlin/error/ErrorManagerTest.java similarity index 100% rename from src/test/java/error/ErrorManagerTest.java rename to src/test/kotlin/error/ErrorManagerTest.java diff --git a/src/test/java/file/FilePositionTrackerTest.java b/src/test/kotlin/file/FilePositionTrackerTest.java similarity index 100% rename from src/test/java/file/FilePositionTrackerTest.java rename to src/test/kotlin/file/FilePositionTrackerTest.java diff --git a/src/test/java/function/ArgumentValidatorTest.java b/src/test/kotlin/function/ArgumentValidatorTest.java similarity index 100% rename from src/test/java/function/ArgumentValidatorTest.java rename to src/test/kotlin/function/ArgumentValidatorTest.java diff --git a/src/test/java/function/LispFunctionTest.java b/src/test/kotlin/function/LispFunctionTest.java similarity index 100% rename from src/test/java/function/LispFunctionTest.java rename to src/test/kotlin/function/LispFunctionTest.java diff --git a/src/test/java/function/LispSpecialFunctionTest.java b/src/test/kotlin/function/LispSpecialFunctionTest.java similarity index 100% rename from src/test/java/function/LispSpecialFunctionTest.java rename to src/test/kotlin/function/LispSpecialFunctionTest.java diff --git a/src/test/java/function/UserDefinedFunctionTest.java b/src/test/kotlin/function/UserDefinedFunctionTest.java similarity index 100% rename from src/test/java/function/UserDefinedFunctionTest.java rename to src/test/kotlin/function/UserDefinedFunctionTest.java diff --git a/src/test/java/function/builtin/APPLYTest.java b/src/test/kotlin/function/builtin/APPLYTest.java similarity index 100% rename from src/test/java/function/builtin/APPLYTest.java rename to src/test/kotlin/function/builtin/APPLYTest.java diff --git a/src/test/java/function/builtin/BackquoteEvaluatorTest.java b/src/test/kotlin/function/builtin/BackquoteEvaluatorTest.java similarity index 100% rename from src/test/java/function/builtin/BackquoteEvaluatorTest.java rename to src/test/kotlin/function/builtin/BackquoteEvaluatorTest.java diff --git a/src/test/java/function/builtin/EVALTest.java b/src/test/kotlin/function/builtin/EVALTest.java similarity index 100% rename from src/test/java/function/builtin/EVALTest.java rename to src/test/kotlin/function/builtin/EVALTest.java diff --git a/src/test/java/function/builtin/EXITTest.java b/src/test/kotlin/function/builtin/EXITTest.java similarity index 100% rename from src/test/java/function/builtin/EXITTest.java rename to src/test/kotlin/function/builtin/EXITTest.java diff --git a/src/test/java/function/builtin/FUNCALLTest.java b/src/test/kotlin/function/builtin/FUNCALLTest.java similarity index 100% rename from src/test/java/function/builtin/FUNCALLTest.java rename to src/test/kotlin/function/builtin/FUNCALLTest.java diff --git a/src/test/java/function/builtin/GENSYMTest.java b/src/test/kotlin/function/builtin/GENSYMTest.java similarity index 100% rename from src/test/java/function/builtin/GENSYMTest.java rename to src/test/kotlin/function/builtin/GENSYMTest.java diff --git a/src/test/java/function/builtin/LOADTest.java b/src/test/kotlin/function/builtin/LOADTest.java similarity index 100% rename from src/test/java/function/builtin/LOADTest.java rename to src/test/kotlin/function/builtin/LOADTest.java diff --git a/src/test/java/function/builtin/PRINTTest.java b/src/test/kotlin/function/builtin/PRINTTest.java similarity index 100% rename from src/test/java/function/builtin/PRINTTest.java rename to src/test/kotlin/function/builtin/PRINTTest.java diff --git a/src/test/java/function/builtin/SETTest.java b/src/test/kotlin/function/builtin/SETTest.java similarity index 98% rename from src/test/java/function/builtin/SETTest.java rename to src/test/kotlin/function/builtin/SETTest.java index 47fb866..14c3c33 100644 --- a/src/test/java/function/builtin/SETTest.java +++ b/src/test/kotlin/function/builtin/SETTest.java @@ -47,7 +47,7 @@ public class SETTest extends SymbolAndFunctionCleaner { public void setLocalVariableDefined_DoesNotSetGlobal() { SymbolTable global = executionContext.getScope(); SymbolTable local = new SymbolTable(global); - local.put("A", new LispNumber("99")); + local.set("A", new LispNumber("99")); executionContext.setScope(local); evaluateString("(set 'a 94)"); diff --git a/src/test/java/function/builtin/SYMBOLSTest.java b/src/test/kotlin/function/builtin/SYMBOLSTest.java similarity index 100% rename from src/test/java/function/builtin/SYMBOLSTest.java rename to src/test/kotlin/function/builtin/SYMBOLSTest.java diff --git a/src/test/java/function/builtin/SYMBOL_FUNCTIONTest.java b/src/test/kotlin/function/builtin/SYMBOL_FUNCTIONTest.java similarity index 100% rename from src/test/java/function/builtin/SYMBOL_FUNCTIONTest.java rename to src/test/kotlin/function/builtin/SYMBOL_FUNCTIONTest.java diff --git a/src/test/java/function/builtin/cons/APPENDTest.java b/src/test/kotlin/function/builtin/cons/APPENDTest.java similarity index 100% rename from src/test/java/function/builtin/cons/APPENDTest.java rename to src/test/kotlin/function/builtin/cons/APPENDTest.java diff --git a/src/test/java/function/builtin/cons/CONSTest.java b/src/test/kotlin/function/builtin/cons/CONSTest.java similarity index 100% rename from src/test/java/function/builtin/cons/CONSTest.java rename to src/test/kotlin/function/builtin/cons/CONSTest.java diff --git a/src/test/java/function/builtin/cons/FIRSTTest.java b/src/test/kotlin/function/builtin/cons/FIRSTTest.java similarity index 100% rename from src/test/java/function/builtin/cons/FIRSTTest.java rename to src/test/kotlin/function/builtin/cons/FIRSTTest.java diff --git a/src/test/java/function/builtin/cons/LENGTHTest.java b/src/test/kotlin/function/builtin/cons/LENGTHTest.java similarity index 100% rename from src/test/java/function/builtin/cons/LENGTHTest.java rename to src/test/kotlin/function/builtin/cons/LENGTHTest.java diff --git a/src/test/java/function/builtin/cons/LISTTest.java b/src/test/kotlin/function/builtin/cons/LISTTest.java similarity index 100% rename from src/test/java/function/builtin/cons/LISTTest.java rename to src/test/kotlin/function/builtin/cons/LISTTest.java diff --git a/src/test/java/function/builtin/cons/RESTTest.java b/src/test/kotlin/function/builtin/cons/RESTTest.java similarity index 100% rename from src/test/java/function/builtin/cons/RESTTest.java rename to src/test/kotlin/function/builtin/cons/RESTTest.java diff --git a/src/test/java/function/builtin/math/DIVIDETest.java b/src/test/kotlin/function/builtin/math/DIVIDETest.java similarity index 100% rename from src/test/java/function/builtin/math/DIVIDETest.java rename to src/test/kotlin/function/builtin/math/DIVIDETest.java diff --git a/src/test/java/function/builtin/math/MINUSTest.java b/src/test/kotlin/function/builtin/math/MINUSTest.java similarity index 100% rename from src/test/java/function/builtin/math/MINUSTest.java rename to src/test/kotlin/function/builtin/math/MINUSTest.java diff --git a/src/test/java/function/builtin/math/MODULOTest.java b/src/test/kotlin/function/builtin/math/MODULOTest.java similarity index 100% rename from src/test/java/function/builtin/math/MODULOTest.java rename to src/test/kotlin/function/builtin/math/MODULOTest.java diff --git a/src/test/java/function/builtin/math/MULTIPLYTest.java b/src/test/kotlin/function/builtin/math/MULTIPLYTest.java similarity index 100% rename from src/test/java/function/builtin/math/MULTIPLYTest.java rename to src/test/kotlin/function/builtin/math/MULTIPLYTest.java diff --git a/src/test/java/function/builtin/math/PLUSTest.java b/src/test/kotlin/function/builtin/math/PLUSTest.java similarity index 100% rename from src/test/java/function/builtin/math/PLUSTest.java rename to src/test/kotlin/function/builtin/math/PLUSTest.java diff --git a/src/test/java/function/builtin/math/REMAINDERTest.java b/src/test/kotlin/function/builtin/math/REMAINDERTest.java similarity index 100% rename from src/test/java/function/builtin/math/REMAINDERTest.java rename to src/test/kotlin/function/builtin/math/REMAINDERTest.java diff --git a/src/test/java/function/builtin/predicate/ATOMTest.java b/src/test/kotlin/function/builtin/predicate/ATOMTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/ATOMTest.java rename to src/test/kotlin/function/builtin/predicate/ATOMTest.java diff --git a/src/test/java/function/builtin/predicate/EQTest.java b/src/test/kotlin/function/builtin/predicate/EQTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/EQTest.java rename to src/test/kotlin/function/builtin/predicate/EQTest.java diff --git a/src/test/java/function/builtin/predicate/EQUALTest.java b/src/test/kotlin/function/builtin/predicate/EQUALTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/EQUALTest.java rename to src/test/kotlin/function/builtin/predicate/EQUALTest.java diff --git a/src/test/java/function/builtin/predicate/GENSYM_EQUALTest.java b/src/test/kotlin/function/builtin/predicate/GENSYM_EQUALTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/GENSYM_EQUALTest.java rename to src/test/kotlin/function/builtin/predicate/GENSYM_EQUALTest.java diff --git a/src/test/java/function/builtin/predicate/LISTPTest.java b/src/test/kotlin/function/builtin/predicate/LISTPTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/LISTPTest.java rename to src/test/kotlin/function/builtin/predicate/LISTPTest.java diff --git a/src/test/java/function/builtin/predicate/NULLTest.java b/src/test/kotlin/function/builtin/predicate/NULLTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/NULLTest.java rename to src/test/kotlin/function/builtin/predicate/NULLTest.java diff --git a/src/test/java/function/builtin/predicate/NUMERIC_EQUALTest.java b/src/test/kotlin/function/builtin/predicate/NUMERIC_EQUALTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/NUMERIC_EQUALTest.java rename to src/test/kotlin/function/builtin/predicate/NUMERIC_EQUALTest.java diff --git a/src/test/java/function/builtin/predicate/NUMERIC_GREATERTest.java b/src/test/kotlin/function/builtin/predicate/NUMERIC_GREATERTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/NUMERIC_GREATERTest.java rename to src/test/kotlin/function/builtin/predicate/NUMERIC_GREATERTest.java diff --git a/src/test/java/function/builtin/predicate/NUMERIC_LESSTest.java b/src/test/kotlin/function/builtin/predicate/NUMERIC_LESSTest.java similarity index 100% rename from src/test/java/function/builtin/predicate/NUMERIC_LESSTest.java rename to src/test/kotlin/function/builtin/predicate/NUMERIC_LESSTest.java diff --git a/src/test/java/function/builtin/special/ANDTest.java b/src/test/kotlin/function/builtin/special/ANDTest.java similarity index 100% rename from src/test/java/function/builtin/special/ANDTest.java rename to src/test/kotlin/function/builtin/special/ANDTest.java diff --git a/src/test/java/function/builtin/special/CASETest.java b/src/test/kotlin/function/builtin/special/CASETest.java similarity index 100% rename from src/test/java/function/builtin/special/CASETest.java rename to src/test/kotlin/function/builtin/special/CASETest.java diff --git a/src/test/java/function/builtin/special/CONDTest.java b/src/test/kotlin/function/builtin/special/CONDTest.java similarity index 100% rename from src/test/java/function/builtin/special/CONDTest.java rename to src/test/kotlin/function/builtin/special/CONDTest.java diff --git a/src/test/java/function/builtin/special/DEFINE_SPECIALTest.java b/src/test/kotlin/function/builtin/special/DEFINE_SPECIALTest.java similarity index 100% rename from src/test/java/function/builtin/special/DEFINE_SPECIALTest.java rename to src/test/kotlin/function/builtin/special/DEFINE_SPECIALTest.java diff --git a/src/test/java/function/builtin/special/DEFMACROTest.java b/src/test/kotlin/function/builtin/special/DEFMACROTest.java similarity index 100% rename from src/test/java/function/builtin/special/DEFMACROTest.java rename to src/test/kotlin/function/builtin/special/DEFMACROTest.java diff --git a/src/test/java/function/builtin/special/DEFUNTest.java b/src/test/kotlin/function/builtin/special/DEFUNTest.java similarity index 100% rename from src/test/java/function/builtin/special/DEFUNTest.java rename to src/test/kotlin/function/builtin/special/DEFUNTest.java diff --git a/src/test/java/function/builtin/special/FUSETest.java b/src/test/kotlin/function/builtin/special/FUSETest.java similarity index 100% rename from src/test/java/function/builtin/special/FUSETest.java rename to src/test/kotlin/function/builtin/special/FUSETest.java diff --git a/src/test/java/function/builtin/special/IFTest.java b/src/test/kotlin/function/builtin/special/IFTest.java similarity index 100% rename from src/test/java/function/builtin/special/IFTest.java rename to src/test/kotlin/function/builtin/special/IFTest.java diff --git a/src/test/java/function/builtin/special/LAMBDATest.java b/src/test/kotlin/function/builtin/special/LAMBDATest.java similarity index 100% rename from src/test/java/function/builtin/special/LAMBDATest.java rename to src/test/kotlin/function/builtin/special/LAMBDATest.java diff --git a/src/test/java/function/builtin/special/LETTest.java b/src/test/kotlin/function/builtin/special/LETTest.java similarity index 100% rename from src/test/java/function/builtin/special/LETTest.java rename to src/test/kotlin/function/builtin/special/LETTest.java diff --git a/src/test/java/function/builtin/special/LET_STARTest.java b/src/test/kotlin/function/builtin/special/LET_STARTest.java similarity index 100% rename from src/test/java/function/builtin/special/LET_STARTest.java rename to src/test/kotlin/function/builtin/special/LET_STARTest.java diff --git a/src/test/java/function/builtin/special/ORTest.java b/src/test/kotlin/function/builtin/special/ORTest.java similarity index 100% rename from src/test/java/function/builtin/special/ORTest.java rename to src/test/kotlin/function/builtin/special/ORTest.java diff --git a/src/test/java/function/builtin/special/PROGNTest.java b/src/test/kotlin/function/builtin/special/PROGNTest.java similarity index 100% rename from src/test/java/function/builtin/special/PROGNTest.java rename to src/test/kotlin/function/builtin/special/PROGNTest.java diff --git a/src/test/java/function/builtin/special/QUOTETest.java b/src/test/kotlin/function/builtin/special/QUOTETest.java similarity index 100% rename from src/test/java/function/builtin/special/QUOTETest.java rename to src/test/kotlin/function/builtin/special/QUOTETest.java diff --git a/src/test/java/function/builtin/special/RECURTest.java b/src/test/kotlin/function/builtin/special/RECURTest.java similarity index 100% rename from src/test/java/function/builtin/special/RECURTest.java rename to src/test/kotlin/function/builtin/special/RECURTest.java diff --git a/src/test/java/function/builtin/special/SETQTest.java b/src/test/kotlin/function/builtin/special/SETQTest.java similarity index 96% rename from src/test/java/function/builtin/special/SETQTest.java rename to src/test/kotlin/function/builtin/special/SETQTest.java index c018a0b..1f63da5 100644 --- a/src/test/java/function/builtin/special/SETQTest.java +++ b/src/test/kotlin/function/builtin/special/SETQTest.java @@ -47,7 +47,7 @@ public class SETQTest extends SymbolAndFunctionCleaner { public void setqLocalVariable() { SymbolTable global = executionContext.getScope(); SymbolTable local = new SymbolTable(global); - local.put("A", new LispNumber("99")); + local.set("A", new LispNumber("99")); executionContext.setScope(local); evaluateString("(setq a 94)"); @@ -58,7 +58,7 @@ public class SETQTest extends SymbolAndFunctionCleaner { public void setqLocalVariableDefined_DoesNotSetGlobal() { SymbolTable global = executionContext.getScope(); SymbolTable local = new SymbolTable(global); - local.put("A", new LispNumber("99")); + local.set("A", new LispNumber("99")); executionContext.setScope(local); evaluateString("(setq a 94)"); diff --git a/src/test/java/interpreter/LispInterpreterTest.java b/src/test/kotlin/interpreter/LispInterpreterTest.java similarity index 100% rename from src/test/java/interpreter/LispInterpreterTest.java rename to src/test/kotlin/interpreter/LispInterpreterTest.java diff --git a/src/test/java/parser/LispParserTest.java b/src/test/kotlin/parser/LispParserTest.java similarity index 100% rename from src/test/java/parser/LispParserTest.java rename to src/test/kotlin/parser/LispParserTest.java diff --git a/src/test/java/recursion/TailCallTest.java b/src/test/kotlin/recursion/TailCallTest.java similarity index 100% rename from src/test/java/recursion/TailCallTest.java rename to src/test/kotlin/recursion/TailCallTest.java diff --git a/src/test/java/scanner/LispCommentRemovingInputStreamTest.java b/src/test/kotlin/scanner/LispCommentRemovingInputStreamTest.java similarity index 100% rename from src/test/java/scanner/LispCommentRemovingInputStreamTest.java rename to src/test/kotlin/scanner/LispCommentRemovingInputStreamTest.java diff --git a/src/test/java/scanner/LispScannerLineColumnTest.java b/src/test/kotlin/scanner/LispScannerLineColumnTest.java similarity index 100% rename from src/test/java/scanner/LispScannerLineColumnTest.java rename to src/test/kotlin/scanner/LispScannerLineColumnTest.java diff --git a/src/test/java/scanner/LispScannerTextTest.java b/src/test/kotlin/scanner/LispScannerTextTest.java similarity index 100% rename from src/test/java/scanner/LispScannerTextTest.java rename to src/test/kotlin/scanner/LispScannerTextTest.java diff --git a/src/test/java/scanner/LispScannerTypeTest.java b/src/test/kotlin/scanner/LispScannerTypeTest.java similarity index 100% rename from src/test/java/scanner/LispScannerTypeTest.java rename to src/test/kotlin/scanner/LispScannerTypeTest.java diff --git a/src/test/java/sexpression/SExpressionTest.java b/src/test/kotlin/sexpression/SExpressionTest.java similarity index 100% rename from src/test/java/sexpression/SExpressionTest.java rename to src/test/kotlin/sexpression/SExpressionTest.java diff --git a/src/test/java/stream/SafeInputStreamTest.java b/src/test/kotlin/stream/SafeInputStreamTest.java similarity index 100% rename from src/test/java/stream/SafeInputStreamTest.java rename to src/test/kotlin/stream/SafeInputStreamTest.java diff --git a/src/test/java/stream/SafeOutputStreamTest.java b/src/test/kotlin/stream/SafeOutputStreamTest.java similarity index 100% rename from src/test/java/stream/SafeOutputStreamTest.java rename to src/test/kotlin/stream/SafeOutputStreamTest.java diff --git a/src/test/java/table/ExecutionContextTest.kt b/src/test/kotlin/table/ExecutionContextTest.kt similarity index 84% rename from src/test/java/table/ExecutionContextTest.kt rename to src/test/kotlin/table/ExecutionContextTest.kt index 9529516..a4ded4f 100644 --- a/src/test/java/table/ExecutionContextTest.kt +++ b/src/test/kotlin/table/ExecutionContextTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS import sexpression.Nil.NIL import sexpression.Symbol.T -import table.ExecutionContext.NullSymbolTable +import table.SymbolTable.NullSymbolTable @TestInstance(PER_CLASS) class ExecutionContextTest { @@ -46,7 +46,7 @@ class ExecutionContextTest { @Test fun `lookup a variable`() { - executionContext.scope.put("test", T) + executionContext.scope["test"] = T assertThat(executionContext.lookupSymbolValue("test")).isEqualTo(T) } @@ -55,7 +55,7 @@ class ExecutionContextTest { fun `lookup a local variable`() { val scope = SymbolTable(executionContext.scope) - scope.put("local", T) + scope["local"] = T executionContext.scope = scope assertThat(executionContext.lookupSymbolValue("local")).isEqualTo(T) @@ -63,10 +63,12 @@ class ExecutionContextTest { @Test fun `lookup a global variable`() { - val scope = SymbolTable(executionContext.scope) - - executionContext.scope.put("global", T) - executionContext.scope = scope + val global = executionContext.scope + val scope1 = SymbolTable(global) + val scope2 = SymbolTable(scope1) + val scope3 = SymbolTable(scope2) + executionContext.scope["global"] = T + executionContext.scope = scope3 assertThat(executionContext.lookupSymbolValue("global")).isEqualTo(T) } @@ -75,8 +77,8 @@ class ExecutionContextTest { fun `lookup a shadowed variable`() { val scope = SymbolTable(executionContext.scope) - scope.put("shadowed", NIL) - executionContext.scope.put("shadowed", T) + scope["shadowed"] = NIL + executionContext.scope["shadowed"] = T executionContext.scope = scope assertThat(executionContext.lookupSymbolValue("shadowed")).isEqualTo(NIL) diff --git a/src/test/java/table/FunctionTableTest.kt b/src/test/kotlin/table/FunctionTableTest.kt similarity index 100% rename from src/test/java/table/FunctionTableTest.kt rename to src/test/kotlin/table/FunctionTableTest.kt diff --git a/src/test/java/table/SymbolTableTest.kt b/src/test/kotlin/table/SymbolTableTest.kt similarity index 76% rename from src/test/java/table/SymbolTableTest.kt rename to src/test/kotlin/table/SymbolTableTest.kt index 8af0072..9c010ce 100644 --- a/src/test/java/table/SymbolTableTest.kt +++ b/src/test/kotlin/table/SymbolTableTest.kt @@ -25,24 +25,24 @@ class SymbolTableTest { @Test fun `lookup a symbol that exists`() { - symbolTable.put("symbol", T) + symbolTable["symbol"] = T assertThat(symbolTable.contains("symbol")).isTrue() } @Test fun `get the value of a symbol`() { - symbolTable.put("symbol", T) + symbolTable["symbol"] = T - assertThat(symbolTable.get("symbol")).isEqualTo(T) + assertThat(symbolTable["symbol"]).isEqualTo(T) } @Test fun `redefine the value of a symbol`() { - symbolTable.put("symbol", T) - symbolTable.put("symbol", NIL) + symbolTable["symbol"] = T + symbolTable["symbol"] = NIL - assertThat(symbolTable.get("symbol")).isEqualTo(NIL) + assertThat(symbolTable["symbol"]).isEqualTo(NIL) } @Test @@ -54,10 +54,10 @@ class SymbolTableTest { @Test fun `lookup a symbol in a parent table`() { - symbolTable.put("symbol", T) + symbolTable["symbol"] = T val childTable = SymbolTable(symbolTable) val parentTable = childTable.parent - assertThat(parentTable.get("symbol")).isEqualTo(T) + assertThat(parentTable?.get("symbol")).isEqualTo(T) } } diff --git a/src/test/java/terminal/ControlSequenceHandlerTest.java b/src/test/kotlin/terminal/ControlSequenceHandlerTest.java similarity index 100% rename from src/test/java/terminal/ControlSequenceHandlerTest.java rename to src/test/kotlin/terminal/ControlSequenceHandlerTest.java diff --git a/src/test/java/terminal/ControlSequenceTest.java b/src/test/kotlin/terminal/ControlSequenceTest.java similarity index 100% rename from src/test/java/terminal/ControlSequenceTest.java rename to src/test/kotlin/terminal/ControlSequenceTest.java diff --git a/src/test/java/terminal/FlushListener.java b/src/test/kotlin/terminal/FlushListener.java similarity index 100% rename from src/test/java/terminal/FlushListener.java rename to src/test/kotlin/terminal/FlushListener.java diff --git a/src/test/java/terminal/LispTerminalTest.java b/src/test/kotlin/terminal/LispTerminalTest.java similarity index 100% rename from src/test/java/terminal/LispTerminalTest.java rename to src/test/kotlin/terminal/LispTerminalTest.java diff --git a/src/test/java/terminal/TerminalConfigurationTest.java b/src/test/kotlin/terminal/TerminalConfigurationTest.java similarity index 100% rename from src/test/java/terminal/TerminalConfigurationTest.java rename to src/test/kotlin/terminal/TerminalConfigurationTest.java diff --git a/src/test/java/terminal/TerminalHistoryTest.java b/src/test/kotlin/terminal/TerminalHistoryTest.java similarity index 100% rename from src/test/java/terminal/TerminalHistoryTest.java rename to src/test/kotlin/terminal/TerminalHistoryTest.java diff --git a/src/test/java/terminal/VirtualTerminalInteractor.java b/src/test/kotlin/terminal/VirtualTerminalInteractor.java similarity index 100% rename from src/test/java/terminal/VirtualTerminalInteractor.java rename to src/test/kotlin/terminal/VirtualTerminalInteractor.java diff --git a/src/test/java/testutil/SymbolAndFunctionCleaner.java b/src/test/kotlin/testutil/SymbolAndFunctionCleaner.java similarity index 100% rename from src/test/java/testutil/SymbolAndFunctionCleaner.java rename to src/test/kotlin/testutil/SymbolAndFunctionCleaner.java diff --git a/src/test/java/testutil/TestUtilities.java b/src/test/kotlin/testutil/TestUtilities.java similarity index 100% rename from src/test/java/testutil/TestUtilities.java rename to src/test/kotlin/testutil/TestUtilities.java diff --git a/src/test/java/testutil/TypeAssertions.java b/src/test/kotlin/testutil/TypeAssertions.java similarity index 100% rename from src/test/java/testutil/TypeAssertions.java rename to src/test/kotlin/testutil/TypeAssertions.java diff --git a/src/test/java/token/TokenFactoryTest.java b/src/test/kotlin/token/TokenFactoryTest.java similarity index 100% rename from src/test/java/token/TokenFactoryTest.java rename to src/test/kotlin/token/TokenFactoryTest.java diff --git a/src/test/java/util/CharactersTest.java b/src/test/kotlin/util/CharactersTest.java similarity index 100% rename from src/test/java/util/CharactersTest.java rename to src/test/kotlin/util/CharactersTest.java diff --git a/src/test/java/util/PathTest.java b/src/test/kotlin/util/PathTest.java similarity index 100% rename from src/test/java/util/PathTest.java rename to src/test/kotlin/util/PathTest.java