27 lines
703 B
Java
27 lines
703 B
Java
package eval;
|
|
|
|
import parser.*;
|
|
|
|
public class EXIT extends LispFunction {
|
|
|
|
// The number of arguments that EXIT takes.
|
|
private static final int NUM_ARGS = 0;
|
|
|
|
public SExpression call(Cons argList) {
|
|
// retrieve the number of arguments passed to EXIT
|
|
int argListLength = LENGTH.getLength(argList);
|
|
|
|
// make sure we have received the proper number of arguments
|
|
if (argListLength > NUM_ARGS) {
|
|
Cons originalSExpr = new Cons(new Symbol("EXIT"), argList);
|
|
String errMsg = "too many arguments given to EXIT: " + originalSExpr;
|
|
|
|
throw new RuntimeException(errMsg);
|
|
}
|
|
|
|
System.exit(0);
|
|
return null;
|
|
}
|
|
|
|
}
|