/* * Name: Mike Cifelli * Course: CIS 443 - Programming Languages * Assignment: Lisp Interpreter 2 */ package eval; import parser.*; /** * NULL represents the NULL function in Lisp. */ public class NULL extends LispFunction { // The number of arguments that NULL takes. private static final int NUM_ARGS = 1; public SExpression call(Cons argList) { // retrieve the number of arguments passed to NULL 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("NULL"), argList); String errMsg = "too " + ((argListLength > NUM_ARGS) ? "many" : "few") + " arguments given to NULL: " + originalSExpr; throw new RuntimeException(errMsg); } SExpression arg = argList.getCar(); return (arg.nullp() ? Symbol.T : Nil.getUniqueInstance()); } }