From f2a481952d3819d19b126b0b4b61592ebc0ea583 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Mon, 13 Mar 2017 09:58:30 -0400 Subject: [PATCH] Add @Override annotations and clean up code --- src/error/ErrorManager.java | 9 +++++++++ src/function/UserDefinedFunction.java | 1 + src/function/builtin/APPLY.java | 1 + src/function/builtin/EVAL.java | 1 + src/function/builtin/EXIT.java | 1 + src/function/builtin/FUNCALL.java | 1 + src/function/builtin/GENSYM.java | 1 + src/function/builtin/LOAD.java | 1 + src/function/builtin/PRINT.java | 1 + src/function/builtin/SET.java | 1 + src/function/builtin/SYMBOL_FUNCTION.java | 1 + src/function/builtin/cons/CONS.java | 1 + src/function/builtin/cons/FIRST.java | 1 + src/function/builtin/cons/LENGTH.java | 1 + src/function/builtin/cons/LIST.java | 1 + src/function/builtin/cons/REST.java | 1 + src/function/builtin/math/DIVIDE.java | 1 + src/function/builtin/math/MINUS.java | 1 + src/function/builtin/math/MULTIPLY.java | 1 + src/function/builtin/math/PLUS.java | 1 + src/function/builtin/predicate/ATOM.java | 1 + src/function/builtin/predicate/EQ.java | 1 + src/function/builtin/predicate/EQUAL.java | 1 + src/function/builtin/predicate/LISTP.java | 1 + src/function/builtin/predicate/NULL.java | 1 + src/function/builtin/predicate/NUMERIC_EQUAL.java | 1 + src/function/builtin/predicate/NUMERIC_GREATER.java | 1 + src/function/builtin/predicate/NUMERIC_LESS.java | 1 + src/function/builtin/special/AND.java | 1 + src/function/builtin/special/CASE.java | 1 + src/function/builtin/special/COND.java | 1 + src/function/builtin/special/Define.java | 1 + src/function/builtin/special/IF.java | 1 + src/function/builtin/special/LAMBDA.java | 1 + src/function/builtin/special/LET.java | 1 + src/function/builtin/special/LET_STAR.java | 1 + src/function/builtin/special/OR.java | 1 + src/function/builtin/special/PROGN.java | 1 + src/function/builtin/special/QUOTE.java | 1 + src/function/builtin/special/SETQ.java | 1 + src/sexpression/AtSignExpression.java | 2 ++ src/sexpression/Atom.java | 2 ++ src/sexpression/BackquoteExpression.java | 2 ++ src/sexpression/CommaExpression.java | 2 ++ src/sexpression/Cons.java | 2 ++ src/sexpression/LambdaExpression.java | 2 ++ src/sexpression/LispNumber.java | 1 + src/sexpression/LispString.java | 1 + src/sexpression/Nil.java | 7 +++++++ src/sexpression/Symbol.java | 1 + src/token/Eof.java | 1 + src/token/RightParenthesis.java | 1 + src/token/TokenFactoryImpl.java | 2 ++ test/interpreter/LispInterpreterBuilderTester.java | 1 + test/testutil/TestUtilities.java | 1 + 55 files changed, 76 insertions(+) diff --git a/src/error/ErrorManager.java b/src/error/ErrorManager.java index 7a78685..d336fa1 100644 --- a/src/error/ErrorManager.java +++ b/src/error/ErrorManager.java @@ -50,32 +50,41 @@ public class ErrorManager { } 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"; } diff --git a/src/function/UserDefinedFunction.java b/src/function/UserDefinedFunction.java index 4ff189e..7882760 100644 --- a/src/function/UserDefinedFunction.java +++ b/src/function/UserDefinedFunction.java @@ -81,6 +81,7 @@ public class UserDefinedFunction extends LispFunction { argumentValidator.setExactNumberOfArguments(this.formalParameters.size()); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/APPLY.java b/src/function/builtin/APPLY.java index fb61a41..72c073f 100644 --- a/src/function/builtin/APPLY.java +++ b/src/function/builtin/APPLY.java @@ -21,6 +21,7 @@ public class APPLY extends LispFunction { this.argumentValidator.setTrailingArgumentExpectedType(Cons.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/EVAL.java b/src/function/builtin/EVAL.java index 8627a38..997964b 100644 --- a/src/function/builtin/EVAL.java +++ b/src/function/builtin/EVAL.java @@ -58,6 +58,7 @@ public class EVAL extends LispFunction { this.argumentValidator.setExactNumberOfArguments(1); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); SExpression argument = argumentList.getFirst(); diff --git a/src/function/builtin/EXIT.java b/src/function/builtin/EXIT.java index 322a459..204d016 100644 --- a/src/function/builtin/EXIT.java +++ b/src/function/builtin/EXIT.java @@ -18,6 +18,7 @@ public class EXIT extends LispFunction { this.environment = RuntimeEnvironment.getInstance(); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); environment.terminateSuccessfully(); diff --git a/src/function/builtin/FUNCALL.java b/src/function/builtin/FUNCALL.java index 50f9da9..86b4029 100644 --- a/src/function/builtin/FUNCALL.java +++ b/src/function/builtin/FUNCALL.java @@ -16,6 +16,7 @@ public class FUNCALL extends LispFunction { this.argumentValidator.setMinimumNumberOfArguments(1); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); Cons applyArgs = new Cons(argumentList.getFirst(), makeList(argumentList.getRest())); diff --git a/src/function/builtin/GENSYM.java b/src/function/builtin/GENSYM.java index cf58c7a..bea2bfa 100644 --- a/src/function/builtin/GENSYM.java +++ b/src/function/builtin/GENSYM.java @@ -29,6 +29,7 @@ public class GENSYM extends LispFunction { this.argumentValidator.setMaximumNumberOfArguments(0); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/LOAD.java b/src/function/builtin/LOAD.java index df5d71f..00b648a 100644 --- a/src/function/builtin/LOAD.java +++ b/src/function/builtin/LOAD.java @@ -29,6 +29,7 @@ public class LOAD extends LispFunction { this.environment = RuntimeEnvironment.getInstance(); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/PRINT.java b/src/function/builtin/PRINT.java index 54e5c2d..2eaff96 100644 --- a/src/function/builtin/PRINT.java +++ b/src/function/builtin/PRINT.java @@ -16,6 +16,7 @@ public class PRINT extends LispFunction { this.environment = RuntimeEnvironment.getInstance(); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); SExpression argument = argumentList.getFirst(); diff --git a/src/function/builtin/SET.java b/src/function/builtin/SET.java index 7bbec2c..ccb6093 100644 --- a/src/function/builtin/SET.java +++ b/src/function/builtin/SET.java @@ -23,6 +23,7 @@ public class SET extends LispFunction { this.executionContext = ExecutionContext.getInstance(); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/SYMBOL_FUNCTION.java b/src/function/builtin/SYMBOL_FUNCTION.java index a4b4f4d..ba65670 100644 --- a/src/function/builtin/SYMBOL_FUNCTION.java +++ b/src/function/builtin/SYMBOL_FUNCTION.java @@ -19,6 +19,7 @@ public class SYMBOL_FUNCTION extends LispFunction { this.argumentValidator.setEveryArgumentExpectedType(Symbol.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/cons/CONS.java b/src/function/builtin/cons/CONS.java index 4d2582b..641669c 100644 --- a/src/function/builtin/cons/CONS.java +++ b/src/function/builtin/cons/CONS.java @@ -13,6 +13,7 @@ public class CONS extends LispFunction { this.argumentValidator.setExactNumberOfArguments(2); } + @Override public Cons call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/cons/FIRST.java b/src/function/builtin/cons/FIRST.java index 975293b..404c5cc 100644 --- a/src/function/builtin/cons/FIRST.java +++ b/src/function/builtin/cons/FIRST.java @@ -14,6 +14,7 @@ public class FIRST extends LispFunction { this.argumentValidator.setEveryArgumentExpectedType(Cons.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); Cons argument = (Cons) argumentList.getFirst(); diff --git a/src/function/builtin/cons/LENGTH.java b/src/function/builtin/cons/LENGTH.java index 25e91d3..1534592 100644 --- a/src/function/builtin/cons/LENGTH.java +++ b/src/function/builtin/cons/LENGTH.java @@ -25,6 +25,7 @@ public class LENGTH extends LispFunction { this.argumentValidator.setEveryArgumentExpectedType(Cons.class); } + @Override public LispNumber call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/cons/LIST.java b/src/function/builtin/cons/LIST.java index 7e85fdf..861cdcc 100644 --- a/src/function/builtin/cons/LIST.java +++ b/src/function/builtin/cons/LIST.java @@ -18,6 +18,7 @@ public class LIST extends LispFunction { this.argumentValidator = new ArgumentValidator(name); } + @Override public Cons call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/cons/REST.java b/src/function/builtin/cons/REST.java index 2a8f7b8..04f5a87 100644 --- a/src/function/builtin/cons/REST.java +++ b/src/function/builtin/cons/REST.java @@ -14,6 +14,7 @@ public class REST extends LispFunction { this.argumentValidator.setEveryArgumentExpectedType(Cons.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); Cons argument = (Cons) argumentList.getFirst(); diff --git a/src/function/builtin/math/DIVIDE.java b/src/function/builtin/math/DIVIDE.java index e9d707d..8d3a642 100644 --- a/src/function/builtin/math/DIVIDE.java +++ b/src/function/builtin/math/DIVIDE.java @@ -18,6 +18,7 @@ public class DIVIDE extends LispFunction { this.mathFunction = new MathFunction(this::getReciprocal, this::divide); } + @Override public LispNumber call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/math/MINUS.java b/src/function/builtin/math/MINUS.java index a87b1b4..232f0e4 100644 --- a/src/function/builtin/math/MINUS.java +++ b/src/function/builtin/math/MINUS.java @@ -18,6 +18,7 @@ public class MINUS extends LispFunction { this.mathFunction = new MathFunction(this::additiveInverse, this::subtract); } + @Override public LispNumber call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/math/MULTIPLY.java b/src/function/builtin/math/MULTIPLY.java index 609da75..42e7454 100644 --- a/src/function/builtin/math/MULTIPLY.java +++ b/src/function/builtin/math/MULTIPLY.java @@ -17,6 +17,7 @@ public class MULTIPLY extends LispFunction { this.mathFunction = new MathFunction(number -> number, this::multiply); } + @Override public LispNumber call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/math/PLUS.java b/src/function/builtin/math/PLUS.java index 3fc0d9d..6b11e75 100644 --- a/src/function/builtin/math/PLUS.java +++ b/src/function/builtin/math/PLUS.java @@ -17,6 +17,7 @@ public class PLUS extends LispFunction { this.mathFunction = new MathFunction(number -> number, this::add); } + @Override public LispNumber call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/predicate/ATOM.java b/src/function/builtin/predicate/ATOM.java index 5fa3c5e..e020724 100644 --- a/src/function/builtin/predicate/ATOM.java +++ b/src/function/builtin/predicate/ATOM.java @@ -16,6 +16,7 @@ public class ATOM extends LispFunction { this.argumentValidator.setExactNumberOfArguments(1); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); SExpression argument = argumentList.getFirst(); diff --git a/src/function/builtin/predicate/EQ.java b/src/function/builtin/predicate/EQ.java index 6b6cf82..48746ce 100644 --- a/src/function/builtin/predicate/EQ.java +++ b/src/function/builtin/predicate/EQ.java @@ -16,6 +16,7 @@ public class EQ extends LispFunction { this.argumentValidator.setExactNumberOfArguments(2); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/predicate/EQUAL.java b/src/function/builtin/predicate/EQUAL.java index c03d161..4bc8df4 100644 --- a/src/function/builtin/predicate/EQUAL.java +++ b/src/function/builtin/predicate/EQUAL.java @@ -20,6 +20,7 @@ public class EQUAL extends LispFunction { this.argumentValidator.setExactNumberOfArguments(2); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/predicate/LISTP.java b/src/function/builtin/predicate/LISTP.java index f3c8ff0..ee3b1a1 100644 --- a/src/function/builtin/predicate/LISTP.java +++ b/src/function/builtin/predicate/LISTP.java @@ -16,6 +16,7 @@ public class LISTP extends LispFunction { this.argumentValidator.setExactNumberOfArguments(1); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/predicate/NULL.java b/src/function/builtin/predicate/NULL.java index 5a1d027..7336b85 100644 --- a/src/function/builtin/predicate/NULL.java +++ b/src/function/builtin/predicate/NULL.java @@ -16,6 +16,7 @@ public class NULL extends LispFunction { this.argumentValidator.setExactNumberOfArguments(1); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/predicate/NUMERIC_EQUAL.java b/src/function/builtin/predicate/NUMERIC_EQUAL.java index aa6dc08..22b0c18 100644 --- a/src/function/builtin/predicate/NUMERIC_EQUAL.java +++ b/src/function/builtin/predicate/NUMERIC_EQUAL.java @@ -17,6 +17,7 @@ public class NUMERIC_EQUAL extends LispFunction { this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/predicate/NUMERIC_GREATER.java b/src/function/builtin/predicate/NUMERIC_GREATER.java index d3920b0..2fdf76f 100644 --- a/src/function/builtin/predicate/NUMERIC_GREATER.java +++ b/src/function/builtin/predicate/NUMERIC_GREATER.java @@ -17,6 +17,7 @@ public class NUMERIC_GREATER extends LispFunction { this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/predicate/NUMERIC_LESS.java b/src/function/builtin/predicate/NUMERIC_LESS.java index 3187e1a..7246098 100644 --- a/src/function/builtin/predicate/NUMERIC_LESS.java +++ b/src/function/builtin/predicate/NUMERIC_LESS.java @@ -17,6 +17,7 @@ public class NUMERIC_LESS extends LispFunction { this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/AND.java b/src/function/builtin/special/AND.java index 2ca1eb2..513cc56 100644 --- a/src/function/builtin/special/AND.java +++ b/src/function/builtin/special/AND.java @@ -15,6 +15,7 @@ public class AND extends LispSpecialFunction { this.argumentValidator = new ArgumentValidator(name); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/CASE.java b/src/function/builtin/special/CASE.java index 8961bde..4f720a1 100644 --- a/src/function/builtin/special/CASE.java +++ b/src/function/builtin/special/CASE.java @@ -20,6 +20,7 @@ public class CASE extends LispSpecialFunction { this.argumentValidator.setTrailingArgumentExcludedType(Nil.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); SExpression key = eval(argumentList.getFirst()); diff --git a/src/function/builtin/special/COND.java b/src/function/builtin/special/COND.java index bceabfa..0dc7684 100644 --- a/src/function/builtin/special/COND.java +++ b/src/function/builtin/special/COND.java @@ -17,6 +17,7 @@ public class COND extends LispSpecialFunction { this.argumentValidator.setEveryArgumentExcludedType(Nil.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/Define.java b/src/function/builtin/special/Define.java index 6575ba5..1eb437d 100644 --- a/src/function/builtin/special/Define.java +++ b/src/function/builtin/special/Define.java @@ -31,6 +31,7 @@ public abstract class Define extends LispSpecialFunction { this.environment = RuntimeEnvironment.getInstance(); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/IF.java b/src/function/builtin/special/IF.java index 8730efa..a34b7f9 100644 --- a/src/function/builtin/special/IF.java +++ b/src/function/builtin/special/IF.java @@ -16,6 +16,7 @@ public class IF extends LispSpecialFunction { this.argumentValidator.setMaximumNumberOfArguments(3); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/LAMBDA.java b/src/function/builtin/special/LAMBDA.java index 57a088d..7146922 100644 --- a/src/function/builtin/special/LAMBDA.java +++ b/src/function/builtin/special/LAMBDA.java @@ -42,6 +42,7 @@ public class LAMBDA extends LispSpecialFunction { this.lambdaListValidator.setEveryArgumentExpectedType(Symbol.class); } + @Override public LambdaExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/LET.java b/src/function/builtin/special/LET.java index e8ab7da..8b388ad 100644 --- a/src/function/builtin/special/LET.java +++ b/src/function/builtin/special/LET.java @@ -31,6 +31,7 @@ public class LET extends LispSpecialFunction { this.executionContext = ExecutionContext.getInstance(); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); Cons variableDefinitions = (Cons) argumentList.getFirst(); diff --git a/src/function/builtin/special/LET_STAR.java b/src/function/builtin/special/LET_STAR.java index 1583037..39dca55 100644 --- a/src/function/builtin/special/LET_STAR.java +++ b/src/function/builtin/special/LET_STAR.java @@ -11,6 +11,7 @@ public class LET_STAR extends LET { super(name); } + @Override protected SymbolTable createLocalScope(Cons variableDefinitions) { SymbolTable localScope = new SymbolTable(executionContext.getScope()); executionContext.setScope(localScope); diff --git a/src/function/builtin/special/OR.java b/src/function/builtin/special/OR.java index b310b92..35d27b2 100644 --- a/src/function/builtin/special/OR.java +++ b/src/function/builtin/special/OR.java @@ -14,6 +14,7 @@ public class OR extends LispSpecialFunction { this.argumentValidator = new ArgumentValidator(name); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/PROGN.java b/src/function/builtin/special/PROGN.java index 739c195..64f4373 100644 --- a/src/function/builtin/special/PROGN.java +++ b/src/function/builtin/special/PROGN.java @@ -15,6 +15,7 @@ public class PROGN extends LispSpecialFunction { this.argumentValidator = new ArgumentValidator(name); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/QUOTE.java b/src/function/builtin/special/QUOTE.java index 3827b59..59fea42 100644 --- a/src/function/builtin/special/QUOTE.java +++ b/src/function/builtin/special/QUOTE.java @@ -13,6 +13,7 @@ public class QUOTE extends LispSpecialFunction { this.argumentValidator.setExactNumberOfArguments(1); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/function/builtin/special/SETQ.java b/src/function/builtin/special/SETQ.java index 7793a2e..637418d 100644 --- a/src/function/builtin/special/SETQ.java +++ b/src/function/builtin/special/SETQ.java @@ -18,6 +18,7 @@ public class SETQ extends LispSpecialFunction { this.argumentValidator.setFirstArgumentExpectedType(Symbol.class); } + @Override public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); diff --git a/src/sexpression/AtSignExpression.java b/src/sexpression/AtSignExpression.java index ff3e894..bb73362 100644 --- a/src/sexpression/AtSignExpression.java +++ b/src/sexpression/AtSignExpression.java @@ -12,10 +12,12 @@ public class AtSignExpression extends SExpression { return expression; } + @Override public boolean isAtSign() { return true; } + @Override public String toString() { return "@" + expression; } diff --git a/src/sexpression/Atom.java b/src/sexpression/Atom.java index e007c15..69c973b 100644 --- a/src/sexpression/Atom.java +++ b/src/sexpression/Atom.java @@ -9,10 +9,12 @@ public abstract class Atom extends SExpression { this.text = text; } + @Override public boolean isAtom() { return true; } + @Override public String toString() { return text; } diff --git a/src/sexpression/BackquoteExpression.java b/src/sexpression/BackquoteExpression.java index 2d8fe73..ec88673 100644 --- a/src/sexpression/BackquoteExpression.java +++ b/src/sexpression/BackquoteExpression.java @@ -12,10 +12,12 @@ public class BackquoteExpression extends SExpression { return expression; } + @Override public boolean isBackquote() { return true; } + @Override public String toString() { return "`" + expression; } diff --git a/src/sexpression/CommaExpression.java b/src/sexpression/CommaExpression.java index 4738004..b10b7a6 100644 --- a/src/sexpression/CommaExpression.java +++ b/src/sexpression/CommaExpression.java @@ -12,10 +12,12 @@ public class CommaExpression extends SExpression { return expression; } + @Override public boolean isComma() { return true; } + @Override public String toString() { return "," + expression; } diff --git a/src/sexpression/Cons.java b/src/sexpression/Cons.java index 9c26e23..3bdbc4b 100644 --- a/src/sexpression/Cons.java +++ b/src/sexpression/Cons.java @@ -27,10 +27,12 @@ public class Cons extends SExpression { this.rest = rest; } + @Override public boolean isCons() { return true; } + @Override public String toString() { return ("(" + toStringAux()); } diff --git a/src/sexpression/LambdaExpression.java b/src/sexpression/LambdaExpression.java index 916fa09..04a9d5c 100644 --- a/src/sexpression/LambdaExpression.java +++ b/src/sexpression/LambdaExpression.java @@ -13,6 +13,7 @@ public class LambdaExpression extends SExpression { this.function = function; } + @Override public boolean isFunction() { return true; } @@ -25,6 +26,7 @@ public class LambdaExpression extends SExpression { return function; } + @Override public String toString() { return lambdaExpression.toString(); } diff --git a/src/sexpression/LispNumber.java b/src/sexpression/LispNumber.java index d465de6..fd511f4 100644 --- a/src/sexpression/LispNumber.java +++ b/src/sexpression/LispNumber.java @@ -29,6 +29,7 @@ public class LispNumber extends Atom { this.value = value; } + @Override public boolean isNumber() { return true; } diff --git a/src/sexpression/LispString.java b/src/sexpression/LispString.java index bc83c81..89898ff 100644 --- a/src/sexpression/LispString.java +++ b/src/sexpression/LispString.java @@ -7,6 +7,7 @@ public class LispString extends Atom { super(text); } + @Override public boolean isString() { return true; } diff --git a/src/sexpression/Nil.java b/src/sexpression/Nil.java index dd2dc80..cf3bc9a 100644 --- a/src/sexpression/Nil.java +++ b/src/sexpression/Nil.java @@ -12,18 +12,22 @@ public class Nil extends Cons { super.setRest(this); } + @Override public boolean isNull() { return true; } + @Override public boolean isAtom() { return true; } + @Override public boolean isCons() { return false; } + @Override public boolean isSymbol() { return true; } @@ -31,13 +35,16 @@ public class Nil extends Cons { /** * The first of NIL can not be changed. */ + @Override public void setFirst(SExpression first) {} /** * The rest of NIL can not be changed. */ + @Override public void setRest(SExpression rest) {} + @Override public String toString() { return "NIL"; } diff --git a/src/sexpression/Symbol.java b/src/sexpression/Symbol.java index 550acdd..811e3b0 100644 --- a/src/sexpression/Symbol.java +++ b/src/sexpression/Symbol.java @@ -13,6 +13,7 @@ public class Symbol extends Atom { super(text.toUpperCase()); } + @Override public boolean isSymbol() { return true; } diff --git a/src/token/Eof.java b/src/token/Eof.java index 2df039b..4034a6b 100644 --- a/src/token/Eof.java +++ b/src/token/Eof.java @@ -25,6 +25,7 @@ public class Eof extends Token { super(position); } + @Override public String getMessagePrefix() { return "end-of-file encountered"; } diff --git a/src/token/RightParenthesis.java b/src/token/RightParenthesis.java index 20f2818..a3e7074 100644 --- a/src/token/RightParenthesis.java +++ b/src/token/RightParenthesis.java @@ -32,6 +32,7 @@ public class RightParenthesis extends Token { super(position); } + @Override public String getMessagePrefix() { return "expression begins with ')'"; } diff --git a/src/token/TokenFactoryImpl.java b/src/token/TokenFactoryImpl.java index 56ea29a..2ee71b4 100644 --- a/src/token/TokenFactoryImpl.java +++ b/src/token/TokenFactoryImpl.java @@ -7,6 +7,7 @@ import file.FilePosition; public class TokenFactoryImpl implements TokenFactory { + @Override public Token createToken(String text, FilePosition position) { if (text.length() == 0) throw new EmptyTokenTextException(position); @@ -51,6 +52,7 @@ public class TokenFactoryImpl implements TokenFactory { return (text.length() > 1) && isDigit(text.charAt(1)); } + @Override public Token createEofToken(FilePosition position) { return new Eof("EOF", position); } diff --git a/test/interpreter/LispInterpreterBuilderTester.java b/test/interpreter/LispInterpreterBuilderTester.java index 5fd8aa5..3ff46de 100644 --- a/test/interpreter/LispInterpreterBuilderTester.java +++ b/test/interpreter/LispInterpreterBuilderTester.java @@ -13,6 +13,7 @@ public class LispInterpreterBuilderTester { private LispInterpreterBuilder builder = new LispInterpreterBuilderImpl() { + @Override public void reset() { this.isBuilt = false; } diff --git a/test/testutil/TestUtilities.java b/test/testutil/TestUtilities.java index d660b7f..b1e22fc 100644 --- a/test/testutil/TestUtilities.java +++ b/test/testutil/TestUtilities.java @@ -21,6 +21,7 @@ public final class TestUtilities { public static InputStream createIOExceptionThrowingInputStream() { return new InputStream() { + @Override public int read() throws IOException { throw new IOException("test IOException"); }