2016-12-19 13:05:53 -05:00
|
|
|
package function.builtin;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2017-02-06 13:39:05 -05:00
|
|
|
import environment.RuntimeEnvironment;
|
2017-01-17 13:54:21 -05:00
|
|
|
import function.*;
|
2016-12-15 15:33:48 -05:00
|
|
|
import sexpression.*;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
|
|
|
public class PRINT extends LispFunction {
|
|
|
|
|
2017-01-17 13:54:21 -05:00
|
|
|
private ArgumentValidator argumentValidator;
|
2017-02-06 13:39:05 -05:00
|
|
|
private RuntimeEnvironment environment;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2017-01-17 13:54:21 -05:00
|
|
|
public PRINT() {
|
|
|
|
this.argumentValidator = new ArgumentValidator("PRINT");
|
|
|
|
this.argumentValidator.setExactNumberOfArguments(1);
|
2017-02-06 13:39:05 -05:00
|
|
|
this.environment = RuntimeEnvironment.getInstance();
|
2017-01-17 13:54:21 -05:00
|
|
|
}
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2017-01-18 16:25:09 -05:00
|
|
|
public SExpression call(Cons argumentList) {
|
|
|
|
argumentValidator.validate(argumentList);
|
2017-02-24 11:07:06 -05:00
|
|
|
SExpression argument = argumentList.getFirst();
|
2017-01-17 13:54:21 -05:00
|
|
|
environment.getOutput().println(argument);
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2017-01-17 13:54:21 -05:00
|
|
|
return argument;
|
2016-12-07 16:38:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|