diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 6f0bc46..2293d97 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -26,6 +26,7 @@
+
diff --git a/src/main/java/error/CriticalLineColumnException.java b/src/main/java/error/CriticalLineColumnException.java
deleted file mode 100644
index def6e1e..0000000
--- a/src/main/java/error/CriticalLineColumnException.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package error;
-
-import error.ErrorManager.Severity;
-import file.FilePosition;
-
-import static error.ErrorManager.Severity.CRITICAL;
-
-public abstract class CriticalLineColumnException extends LineColumnException {
-
- private static final long serialVersionUID = 1L;
-
- public CriticalLineColumnException(FilePosition position) {
- super(position);
- }
-
- @Override
- public Severity getSeverity() {
- return CRITICAL;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/error/CriticalLineColumnException.kt b/src/main/java/error/CriticalLineColumnException.kt
new file mode 100644
index 0000000..5ef408c
--- /dev/null
+++ b/src/main/java/error/CriticalLineColumnException.kt
@@ -0,0 +1,9 @@
+package error
+
+import error.Severity.CRITICAL
+import file.FilePosition
+
+abstract class CriticalLineColumnException(position: FilePosition) : LineColumnException(position) {
+
+ override val severity = CRITICAL
+}
\ No newline at end of file
diff --git a/src/main/java/error/CriticalLispException.java b/src/main/java/error/CriticalLispException.java
deleted file mode 100644
index 7707f25..0000000
--- a/src/main/java/error/CriticalLispException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package error;
-
-import error.ErrorManager.Severity;
-
-import static error.ErrorManager.Severity.CRITICAL;
-
-public abstract class CriticalLispException extends LispException {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Severity getSeverity() {
- return CRITICAL;
- }
-}
diff --git a/src/main/java/error/CriticalLispException.kt b/src/main/java/error/CriticalLispException.kt
new file mode 100644
index 0000000..69e9a6c
--- /dev/null
+++ b/src/main/java/error/CriticalLispException.kt
@@ -0,0 +1,8 @@
+package error
+
+import error.Severity.CRITICAL
+
+abstract class CriticalLispException : LispException() {
+
+ override val severity = CRITICAL
+}
diff --git a/src/main/java/error/ErrorManager.java b/src/main/java/error/ErrorManager.java
deleted file mode 100644
index 8875809..0000000
--- a/src/main/java/error/ErrorManager.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package error;
-
-import environment.RuntimeEnvironment;
-
-import java.io.PrintStream;
-
-import static error.ErrorManager.Severity.CRITICAL;
-import static error.ErrorManager.Severity.WARNING;
-import static java.text.MessageFormat.format;
-
-/**
- * Prints error messages and potentially terminates the application.
- */
-public class ErrorManager {
-
- private RuntimeEnvironment environment;
-
- public ErrorManager() {
- this.environment = RuntimeEnvironment.getInstance();
- }
-
- public void handle(LispException lispException) {
- printMessage(lispException);
-
- if (isCritical(lispException))
- environment.terminateExceptionally();
- }
-
- private void printMessage(LispException lispException) {
- PrintStream output = selectOutputStream(lispException.getSeverity());
- output.println(formatMessage(lispException));
- }
-
- private PrintStream selectOutputStream(Severity severity) {
- if (severity == WARNING)
- return environment.getOutput();
-
- return environment.getErrorOutput();
- }
-
- private String formatMessage(LispException lispException) {
- Severity severity = lispException.getSeverity();
- String prefix = severity.toDisplayString();
- String message = format("[{0}] {1}", prefix, lispException.getMessage());
-
- return severity.decorate(message, environment);
- }
-
- private boolean isCritical(LispException lispException) {
- return lispException.getSeverity() == CRITICAL;
- }
-
- public static enum Severity {
-
- WARNING {
- @Override
- public String decorate(String warningOutput, RuntimeEnvironment environment) {
- return environment.decorateWarningOutput(warningOutput);
- }
-
- @Override
- public String toDisplayString() {
- return "warning";
- }
- },
-
- ERROR {
- @Override
- public String decorate(String errorOutput, RuntimeEnvironment environment) {
- return environment.decorateErrorOutput(errorOutput);
- }
-
- @Override
- public String toDisplayString() {
- return "error";
- }
- },
-
- CRITICAL {
- @Override
- public String decorate(String criticalOutput, RuntimeEnvironment environment) {
- return environment.decorateCriticalOutput(criticalOutput);
- }
-
- @Override
- public String toDisplayString() {
- return "critical";
- }
- };
-
- public abstract String decorate(String output, RuntimeEnvironment environment);
-
- public abstract String toDisplayString();
- }
-}
diff --git a/src/main/java/error/ErrorManager.kt b/src/main/java/error/ErrorManager.kt
new file mode 100644
index 0000000..ea4f1b1
--- /dev/null
+++ b/src/main/java/error/ErrorManager.kt
@@ -0,0 +1,41 @@
+package error
+
+import environment.RuntimeEnvironment
+import error.Severity.CRITICAL
+import error.Severity.WARNING
+import java.io.PrintStream
+import java.text.MessageFormat.format
+
+/**
+ * Prints error messages and potentially terminates the application.
+ */
+class ErrorManager {
+
+ private val environment: RuntimeEnvironment = RuntimeEnvironment.getInstance()
+
+ fun handle(lispException: LispException) {
+ printMessage(lispException)
+
+ if (isCritical(lispException))
+ environment.terminateExceptionally()
+ }
+
+ private fun printMessage(lispException: LispException) {
+ val output = selectOutputStream(lispException.severity)
+ output.println(formatMessage(lispException))
+ }
+
+ private fun selectOutputStream(severity: Severity): PrintStream {
+ return if (severity === WARNING) environment.output else environment.errorOutput
+ }
+
+ private fun formatMessage(lispException: LispException): String {
+ val severity = lispException.severity
+ val prefix = severity.toDisplayString()
+ val message = format("[{0}] {1}", prefix, lispException.message)
+
+ return severity.decorate(message, environment)
+ }
+
+ private fun isCritical(lispException: LispException) = lispException.severity == CRITICAL
+}
diff --git a/src/main/java/error/LineColumnException.java b/src/main/java/error/LineColumnException.java
deleted file mode 100644
index f02779f..0000000
--- a/src/main/java/error/LineColumnException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package error;
-
-import file.FilePosition;
-
-import static java.text.MessageFormat.format;
-
-public abstract class LineColumnException extends LispException {
-
- private static final long serialVersionUID = 1L;
- private FilePosition position;
-
- public LineColumnException(FilePosition position) {
- this.position = position;
- }
-
- @Override
- public String getMessage() {
- return format("{0} - line {1}, column {2}",
- getMessagePrefix(),
- position.getLineNumber(),
- position.getColumnNumber());
- }
-
- public abstract String getMessagePrefix();
-}
\ No newline at end of file
diff --git a/src/main/java/error/LineColumnException.kt b/src/main/java/error/LineColumnException.kt
new file mode 100644
index 0000000..f2eb7e0
--- /dev/null
+++ b/src/main/java/error/LineColumnException.kt
@@ -0,0 +1,12 @@
+package error
+
+import file.FilePosition
+import java.text.MessageFormat.format
+
+abstract class LineColumnException(private val position: FilePosition) : LispException() {
+
+ abstract val messagePrefix: String
+
+ override val message: String
+ get() = format("{0} - line {1}, column {2}", messagePrefix, position.lineNumber, position.columnNumber)
+}
\ No newline at end of file
diff --git a/src/main/java/error/LispException.java b/src/main/java/error/LispException.java
deleted file mode 100644
index 22089af..0000000
--- a/src/main/java/error/LispException.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package error;
-
-import error.ErrorManager.Severity;
-
-import static error.ErrorManager.Severity.ERROR;
-
-public abstract class LispException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public Severity getSeverity() {
- return ERROR;
- }
-}
diff --git a/src/main/java/error/LispException.kt b/src/main/java/error/LispException.kt
new file mode 100644
index 0000000..b5a6dec
--- /dev/null
+++ b/src/main/java/error/LispException.kt
@@ -0,0 +1,8 @@
+package error
+
+import error.Severity.ERROR
+
+abstract class LispException : RuntimeException() {
+
+ open val severity = ERROR
+}
diff --git a/src/main/java/error/LispWarning.java b/src/main/java/error/LispWarning.java
deleted file mode 100644
index a0799a0..0000000
--- a/src/main/java/error/LispWarning.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package error;
-
-import error.ErrorManager.Severity;
-
-import static error.ErrorManager.Severity.WARNING;
-
-public abstract class LispWarning extends LispException {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Severity getSeverity() {
- return WARNING;
- }
-}
diff --git a/src/main/java/error/LispWarning.kt b/src/main/java/error/LispWarning.kt
new file mode 100644
index 0000000..37abb6f
--- /dev/null
+++ b/src/main/java/error/LispWarning.kt
@@ -0,0 +1,8 @@
+package error
+
+import error.Severity.WARNING
+
+abstract class LispWarning : LispException() {
+
+ override val severity = WARNING
+}
diff --git a/src/main/java/error/Severity.kt b/src/main/java/error/Severity.kt
new file mode 100644
index 0000000..fe146ae
--- /dev/null
+++ b/src/main/java/error/Severity.kt
@@ -0,0 +1,31 @@
+package error
+
+import environment.RuntimeEnvironment
+
+enum class Severity {
+
+ WARNING {
+ override fun decorate(output: String, environment: RuntimeEnvironment): String =
+ environment.decorateWarningOutput(output)
+
+ override fun toDisplayString() = "warning"
+ },
+
+ ERROR {
+ override fun decorate(output: String, environment: RuntimeEnvironment): String =
+ environment.decorateErrorOutput(output)
+
+ override fun toDisplayString() = "error"
+ },
+
+ CRITICAL {
+ override fun decorate(output: String, environment: RuntimeEnvironment): String =
+ environment.decorateCriticalOutput(output)
+
+ override fun toDisplayString() = "critical"
+ };
+
+ abstract fun decorate(output: String, environment: RuntimeEnvironment): String
+
+ abstract fun toDisplayString(): String
+}
\ No newline at end of file
diff --git a/src/test/java/error/ErrorManagerTest.java b/src/test/java/error/ErrorManagerTest.java
index 2793f12..fbc0fd3 100644
--- a/src/test/java/error/ErrorManagerTest.java
+++ b/src/test/java/error/ErrorManagerTest.java
@@ -1,7 +1,6 @@
package error;
import environment.RuntimeEnvironment;
-import error.ErrorManager.Severity;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -11,9 +10,9 @@ import java.io.PrintStream;
import java.util.HashSet;
import java.util.Set;
-import static error.ErrorManager.Severity.CRITICAL;
-import static error.ErrorManager.Severity.ERROR;
-import static error.ErrorManager.Severity.WARNING;
+import static error.Severity.CRITICAL;
+import static error.Severity.ERROR;
+import static error.Severity.WARNING;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/function/ArgumentValidatorTest.java b/src/test/java/function/ArgumentValidatorTest.java
index d284caf..c3ded9d 100644
--- a/src/test/java/function/ArgumentValidatorTest.java
+++ b/src/test/java/function/ArgumentValidatorTest.java
@@ -12,7 +12,7 @@ import sexpression.Nil;
import sexpression.SExpression;
import sexpression.Symbol;
-import static error.ErrorManager.Severity.ERROR;
+import static error.Severity.ERROR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/function/UserDefinedFunctionTest.java b/src/test/java/function/UserDefinedFunctionTest.java
index 29cd20f..cb3334b 100644
--- a/src/test/java/function/UserDefinedFunctionTest.java
+++ b/src/test/java/function/UserDefinedFunctionTest.java
@@ -1,6 +1,6 @@
package function;
-import error.ErrorManager;
+import error.Severity;
import function.ArgumentValidator.TooFewArgumentsException;
import function.ArgumentValidator.TooManyArgumentsException;
import function.UserDefinedFunction.IllegalKeywordRestPositionException;
@@ -74,6 +74,6 @@ public class UserDefinedFunctionTest {
assertNotNull(e.getMessage());
assertTrue(e.getMessage().length() > 0);
- assertEquals(ErrorManager.Severity.ERROR, e.getSeverity());
+ assertEquals(Severity.ERROR, e.getSeverity());
}
}
diff --git a/src/test/java/function/builtin/SYMBOL_FUNCTIONTest.java b/src/test/java/function/builtin/SYMBOL_FUNCTIONTest.java
index 44d32dd..9aeb813 100644
--- a/src/test/java/function/builtin/SYMBOL_FUNCTIONTest.java
+++ b/src/test/java/function/builtin/SYMBOL_FUNCTIONTest.java
@@ -7,7 +7,7 @@ import function.builtin.SYMBOL_FUNCTION.UndefinedSymbolFunctionException;
import org.junit.Test;
import testutil.SymbolAndFunctionCleaner;
-import static error.ErrorManager.Severity.ERROR;
+import static error.Severity.ERROR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/interpreter/LispInterpreterTest.java b/src/test/java/interpreter/LispInterpreterTest.java
index 0619a27..659f096 100644
--- a/src/test/java/interpreter/LispInterpreterTest.java
+++ b/src/test/java/interpreter/LispInterpreterTest.java
@@ -11,7 +11,7 @@ import java.io.PrintStream;
import java.util.HashSet;
import java.util.Set;
-import static error.ErrorManager.Severity.CRITICAL;
+import static error.Severity.CRITICAL;
import static interpreter.InteractiveLispInterpreter.PROMPT;
import static java.text.MessageFormat.format;
import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/parser/LispParserTest.java b/src/test/java/parser/LispParserTest.java
index 13f15b0..af6b15a 100644
--- a/src/test/java/parser/LispParserTest.java
+++ b/src/test/java/parser/LispParserTest.java
@@ -10,7 +10,7 @@ import token.TokenFactory.BadCharacterException;
import java.io.InputStream;
-import static error.ErrorManager.Severity.ERROR;
+import static error.Severity.ERROR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
diff --git a/src/test/java/scanner/LispCommentRemovingInputStreamTest.java b/src/test/java/scanner/LispCommentRemovingInputStreamTest.java
index ae986f4..abf3c05 100644
--- a/src/test/java/scanner/LispCommentRemovingInputStreamTest.java
+++ b/src/test/java/scanner/LispCommentRemovingInputStreamTest.java
@@ -6,7 +6,7 @@ import stream.UncheckedIOException;
import java.io.InputStream;
-import static error.ErrorManager.Severity.CRITICAL;
+import static error.Severity.CRITICAL;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/scanner/LispScannerTypeTest.java b/src/test/java/scanner/LispScannerTypeTest.java
index 7a5fe62..04f686b 100644
--- a/src/test/java/scanner/LispScannerTypeTest.java
+++ b/src/test/java/scanner/LispScannerTypeTest.java
@@ -20,7 +20,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
-import static error.ErrorManager.Severity.ERROR;
+import static error.Severity.ERROR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/sexpression/SExpressionTest.java b/src/test/java/sexpression/SExpressionTest.java
index da9dfc8..ab8e99e 100644
--- a/src/test/java/sexpression/SExpressionTest.java
+++ b/src/test/java/sexpression/SExpressionTest.java
@@ -7,7 +7,7 @@ import sexpression.LispNumber.InvalidNumberException;
import java.math.BigInteger;
import java.util.Locale;
-import static error.ErrorManager.Severity.ERROR;
+import static error.Severity.ERROR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/table/FunctionTableTest.java b/src/test/java/table/FunctionTableTest.java
index a02facb..266166e 100644
--- a/src/test/java/table/FunctionTableTest.java
+++ b/src/test/java/table/FunctionTableTest.java
@@ -1,6 +1,6 @@
package table;
-import error.ErrorManager;
+import error.Severity;
import function.FunctionNames;
import function.LispFunction;
import org.junit.After;
@@ -146,7 +146,7 @@ public class FunctionTableTest {
assertNotNull(e.getMessage());
assertTrue(e.getMessage().length() > 0);
- assertEquals(ErrorManager.Severity.CRITICAL, e.getSeverity());
+ assertEquals(Severity.CRITICAL, e.getSeverity());
}
@Test
diff --git a/src/test/java/testutil/TestUtilities.java b/src/test/java/testutil/TestUtilities.java
index c7a9edf..2f8c3db 100644
--- a/src/test/java/testutil/TestUtilities.java
+++ b/src/test/java/testutil/TestUtilities.java
@@ -11,7 +11,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
-import static error.ErrorManager.Severity.ERROR;
+import static error.Severity.ERROR;
import static function.builtin.EVAL.eval;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
diff --git a/src/test/java/token/TokenFactoryTest.java b/src/test/java/token/TokenFactoryTest.java
index e7a742f..2354909 100644
--- a/src/test/java/token/TokenFactoryTest.java
+++ b/src/test/java/token/TokenFactoryTest.java
@@ -6,7 +6,7 @@ import org.junit.Test;
import token.TokenFactory.BadCharacterException;
import token.TokenFactory.EmptyTokenTextException;
-import static error.ErrorManager.Severity.CRITICAL;
+import static error.Severity.CRITICAL;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;