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