32 lines
781 B
Java
32 lines
781 B
Java
/*
|
|
* Name: Mike Cifelli
|
|
* Course: CIS 443 - Programming Languages
|
|
* Assignment: Lisp Interpreter 2
|
|
*/
|
|
|
|
package eval;
|
|
|
|
import parser.*;
|
|
|
|
/**
|
|
* <code>FUNCALL</code> represents the FUNCALL function in Lisp.
|
|
*/
|
|
public class FUNCALL extends LispFunction {
|
|
|
|
public SExpression call(Cons argList) {
|
|
// make sure we have received at least one argument
|
|
if (argList.nullp()) {
|
|
Cons originalSExpr = new Cons(new Symbol("FUNCALL"), argList);
|
|
|
|
throw new RuntimeException("too few arguments given to FUNCALL: " +
|
|
originalSExpr);
|
|
}
|
|
|
|
SExpression cdr = argList.getCdr();
|
|
Cons applyArgs = new Cons(argList.getCar(), LIST.makeList(cdr));
|
|
|
|
return APPLY.apply(applyArgs);
|
|
}
|
|
|
|
}
|