Formatted several files
This commit is contained in:
parent
913fd031c6
commit
b6d717ec1c
|
@ -57,7 +57,7 @@ public class RuntimeEnvironment {
|
|||
public void terminateSuccessfully() {
|
||||
terminationFunction.run();
|
||||
}
|
||||
|
||||
|
||||
public void terminateExceptionally() {
|
||||
errorTerminationFunction.run();
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package error;
|
|||
public abstract class LispException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public int getSeverity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ public class FilePositionTracker {
|
|||
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
|
||||
public void incrementColumn() {
|
||||
columnNumber++;
|
||||
}
|
||||
|
||||
|
||||
public void incrementLine() {
|
||||
lineNumber++;
|
||||
columnNumber = 0;
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LOAD extends LispFunction {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class SYMBOL_FUNCTION extends LispFunction {
|
|||
|
||||
return new Symbol(MessageFormat.format("#<SYSTEM-FUNCTION {0}>", symbol.toString()));
|
||||
}
|
||||
|
||||
|
||||
throw new UndefinedSymbolFunctionException(symbol);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import error.LispException;
|
|||
|
||||
@DisplayName("number")
|
||||
public class LispNumber extends Atom {
|
||||
|
||||
|
||||
public static final LispNumber ZERO = new LispNumber(BigInteger.ZERO);
|
||||
public static final LispNumber ONE = new LispNumber(BigInteger.ONE);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package sexpression;
|
|||
public class Symbol extends Atom {
|
||||
|
||||
public static final Symbol T = new Symbol("T");
|
||||
|
||||
|
||||
public static Symbol createQuote() {
|
||||
return new Symbol("QUOTE");
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import sexpression.SExpression;
|
|||
public class ExecutionContext {
|
||||
|
||||
private static ExecutionContext uniqueInstance = new ExecutionContext();
|
||||
|
||||
|
||||
public static ExecutionContext getInstance() {
|
||||
return uniqueInstance;
|
||||
}
|
||||
|
||||
|
||||
private SymbolTable scope;
|
||||
|
||||
|
||||
private ExecutionContext() {
|
||||
this.scope = new SymbolTable();
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ public class ExecutionContext {
|
|||
public SymbolTable getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
|
||||
public void setScope(SymbolTable scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
|
||||
public void clearContext() {
|
||||
this.scope = new SymbolTable();
|
||||
}
|
||||
|
|
|
@ -10,25 +10,25 @@ import function.builtin.predicate.*;
|
|||
import function.builtin.special.*;
|
||||
|
||||
public class FunctionTable {
|
||||
|
||||
|
||||
private static FunctionTable uniqueInstance = new FunctionTable();
|
||||
|
||||
|
||||
public static LispFunction lookupFunction(String functionName) {
|
||||
return uniqueInstance.functionTable.get(functionName);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isAlreadyDefined(String functionName) {
|
||||
return uniqueInstance.functionTable.containsKey(functionName);
|
||||
}
|
||||
|
||||
|
||||
public static void defineFunction(String functionName, LispFunction function) {
|
||||
uniqueInstance.functionTable.put(functionName, function);
|
||||
}
|
||||
|
||||
|
||||
public static void reset() {
|
||||
uniqueInstance.initializeFunctionTable();
|
||||
}
|
||||
|
||||
|
||||
private HashMap<String, LispFunction> functionTable;
|
||||
|
||||
private FunctionTable() {
|
||||
|
|
|
@ -21,7 +21,7 @@ public abstract class Token {
|
|||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
public FilePosition getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ public class UserDefinedFunctionTester {
|
|||
public void testNilFunctionToString() {
|
||||
UserDefinedFunction function = createNoArgumentFunctionThatReturnsNil();
|
||||
Cons expected = new Cons(new Symbol(FUNCTION_NAME),
|
||||
new Cons(Nil.getInstance(),
|
||||
new Cons(Nil.getInstance(), Nil.getInstance())));
|
||||
new Cons(Nil.getInstance(), new Cons(Nil.getInstance(), Nil.getInstance())));
|
||||
|
||||
assertSExpressionsMatch(expected, function.getLambdaExpression());
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class CONSTester {
|
|||
|
||||
assertSExpressionsMatch(parseString("(1 2 3)"), evaluateString(input));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConsWithTwoLists() {
|
||||
String input = "(cons '(1 2) '(3 4))";
|
||||
|
@ -36,7 +37,6 @@ public class CONSTester {
|
|||
assertSExpressionsMatch(parseString("((1 2) 3 4)"), evaluateString(input));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConsWithList() {
|
||||
String input = "(cons nil '(2 3))";
|
||||
|
|
Loading…
Reference in New Issue