74 lines
1.5 KiB
Java
74 lines
1.5 KiB
Java
/*
|
|
* Name: Mike Cifelli
|
|
* Course: CIS 443 - Programming Languages
|
|
* Assignment: Lisp Interpreter 2
|
|
*/
|
|
|
|
package eval;
|
|
|
|
import parser.*;
|
|
|
|
/**
|
|
* This class represents a Lisp FUNCTION in the PL-Lisp implementation.
|
|
*/
|
|
public class LambdaExpression extends SExpression {
|
|
|
|
private Cons lexpr;
|
|
private UDFunction function;
|
|
|
|
/**
|
|
* Create a new FUNCTION with the specified lambda expression and
|
|
* internal representation.
|
|
*
|
|
* @param lexpr
|
|
* the lambda expression of this FUNCTION
|
|
* @param function
|
|
* the internal representation of this FUNCTION
|
|
*/
|
|
public LambdaExpression(Cons lexpr, UDFunction function) {
|
|
this.lexpr = lexpr;
|
|
this.function = function;
|
|
}
|
|
|
|
/**
|
|
* Test if this S-expression is a FUNCTION.
|
|
*
|
|
* @return
|
|
* <code>true</code>
|
|
*/
|
|
public boolean functionp() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the lambda expression of this FUNCTION.
|
|
*
|
|
* @return
|
|
* the lambda expression of this FUNCTION
|
|
*/
|
|
public Cons getLExpression() {
|
|
return lexpr;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the internal representation of this FUNCTION.
|
|
*
|
|
* @return
|
|
* the user-defined function of this FUNCTION
|
|
*/
|
|
public UDFunction getFunction() {
|
|
return function;
|
|
}
|
|
|
|
/**
|
|
* Returns a string representation of this FUNCTION.
|
|
*
|
|
* @return
|
|
* a string representation of this FUNCTION
|
|
*/
|
|
public String toString() {
|
|
return lexpr.toString();
|
|
}
|
|
|
|
}
|