Update import arrangement
This commit is contained in:
parent
d0cffe7500
commit
bd7df920fa
|
@ -4,6 +4,19 @@
|
||||||
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
|
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
|
||||||
<option name="ANNOTATION_PARAMETER_WRAP" value="5" />
|
<option name="ANNOTATION_PARAMETER_WRAP" value="5" />
|
||||||
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
|
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
|
||||||
|
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
||||||
|
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
||||||
|
<option name="IMPORT_LAYOUT_TABLE">
|
||||||
|
<value>
|
||||||
|
<emptyLine />
|
||||||
|
<package name="" withSubpackages="true" static="false" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="javax" withSubpackages="true" static="false" />
|
||||||
|
<package name="java" withSubpackages="true" static="false" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="" withSubpackages="true" static="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
</JavaCodeStyleSettings>
|
</JavaCodeStyleSettings>
|
||||||
<XML>
|
<XML>
|
||||||
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package application;
|
package application;
|
||||||
|
|
||||||
import static com.googlecode.lanterna.terminal.IOSafeTerminalAdapter.createRuntimeExceptionConvertingAdapter;
|
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
|
||||||
import static java.text.MessageFormat.format;
|
import com.googlecode.lanterna.terminal.IOSafeTerminal;
|
||||||
import static terminal.LispTerminal.END_OF_SEGMENT;
|
import com.googlecode.lanterna.terminal.Terminal;
|
||||||
|
import interpreter.LispInterpreter;
|
||||||
|
import interpreter.LispInterpreterBuilder;
|
||||||
|
import interpreter.LispInterpreterBuilderImpl;
|
||||||
|
import stream.UncheckedIOException;
|
||||||
|
import terminal.LispTerminal;
|
||||||
|
import terminal.TerminalConfiguration;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PipedInputStream;
|
import java.io.PipedInputStream;
|
||||||
|
@ -10,16 +16,9 @@ import java.io.PipedOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
|
import static com.googlecode.lanterna.terminal.IOSafeTerminalAdapter.createRuntimeExceptionConvertingAdapter;
|
||||||
import com.googlecode.lanterna.terminal.IOSafeTerminal;
|
import static java.text.MessageFormat.format;
|
||||||
import com.googlecode.lanterna.terminal.Terminal;
|
import static terminal.LispTerminal.END_OF_SEGMENT;
|
||||||
|
|
||||||
import interpreter.LispInterpreter;
|
|
||||||
import interpreter.LispInterpreterBuilder;
|
|
||||||
import interpreter.LispInterpreterBuilderImpl;
|
|
||||||
import stream.UncheckedIOException;
|
|
||||||
import terminal.LispTerminal;
|
|
||||||
import terminal.TerminalConfiguration;
|
|
||||||
|
|
||||||
public class LispMain {
|
public class LispMain {
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package environment;
|
package environment;
|
||||||
|
|
||||||
|
import error.ErrorManager;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import error.ErrorManager;
|
|
||||||
|
|
||||||
public class RuntimeEnvironment {
|
public class RuntimeEnvironment {
|
||||||
|
|
||||||
private static RuntimeEnvironment uniqueInstance = new RuntimeEnvironment();
|
private static RuntimeEnvironment uniqueInstance = new RuntimeEnvironment();
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package error;
|
package error;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.CRITICAL;
|
|
||||||
|
|
||||||
import error.ErrorManager.Severity;
|
import error.ErrorManager.Severity;
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
|
|
||||||
|
import static error.ErrorManager.Severity.CRITICAL;
|
||||||
|
|
||||||
public abstract class CriticalLineColumnException extends LineColumnException {
|
public abstract class CriticalLineColumnException extends LineColumnException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package error;
|
package error;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.CRITICAL;
|
|
||||||
|
|
||||||
import error.ErrorManager.Severity;
|
import error.ErrorManager.Severity;
|
||||||
|
|
||||||
|
import static error.ErrorManager.Severity.CRITICAL;
|
||||||
|
|
||||||
public abstract class CriticalLispException extends LispException {
|
public abstract class CriticalLispException extends LispException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package error;
|
package error;
|
||||||
|
|
||||||
|
import environment.RuntimeEnvironment;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.CRITICAL;
|
import static error.ErrorManager.Severity.CRITICAL;
|
||||||
import static error.ErrorManager.Severity.WARNING;
|
import static error.ErrorManager.Severity.WARNING;
|
||||||
import static java.text.MessageFormat.format;
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints error messages and potentially terminates the application.
|
* Prints error messages and potentially terminates the application.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package error;
|
package error;
|
||||||
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
|
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
public abstract class LineColumnException extends LispException {
|
public abstract class LineColumnException extends LispException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package error;
|
package error;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.ERROR;
|
|
||||||
|
|
||||||
import error.ErrorManager.Severity;
|
import error.ErrorManager.Severity;
|
||||||
|
|
||||||
|
import static error.ErrorManager.Severity.ERROR;
|
||||||
|
|
||||||
public abstract class LispException extends RuntimeException {
|
public abstract class LispException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package error;
|
package error;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.WARNING;
|
|
||||||
|
|
||||||
import error.ErrorManager.Severity;
|
import error.ErrorManager.Severity;
|
||||||
|
|
||||||
|
import static error.ErrorManager.Severity.WARNING;
|
||||||
|
|
||||||
public abstract class LispWarning extends LispException {
|
public abstract class LispWarning extends LispException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package function;
|
package function;
|
||||||
|
|
||||||
import static function.builtin.cons.LENGTH.getLength;
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.DisplayName;
|
import sexpression.DisplayName;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import static function.builtin.cons.LENGTH.getLength;
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
public class ArgumentValidator {
|
public class ArgumentValidator {
|
||||||
|
|
||||||
private Class<? extends SExpression> firstArgumentType;
|
private Class<? extends SExpression> firstArgumentType;
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package function;
|
package function;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import recursion.TailCall;
|
import recursion.TailCall;
|
||||||
import recursion.TailCalls;
|
import recursion.TailCalls;
|
||||||
|
@ -16,6 +9,13 @@ import sexpression.Symbol;
|
||||||
import table.ExecutionContext;
|
import table.ExecutionContext;
|
||||||
import table.SymbolTable;
|
import table.SymbolTable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
public class UserDefinedFunction extends LispFunction {
|
public class UserDefinedFunction extends LispFunction {
|
||||||
|
|
||||||
private static final String KEYWORD_REST = "&REST";
|
private static final String KEYWORD_REST = "&REST";
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static function.builtin.EVAL.applyFunction;
|
|
||||||
import static function.builtin.EVAL.lookupFunctionOrLambda;
|
|
||||||
import static table.FunctionTable.lookupFunction;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.applyFunction;
|
||||||
|
import static function.builtin.EVAL.lookupFunctionOrLambda;
|
||||||
|
import static table.FunctionTable.lookupFunction;
|
||||||
|
|
||||||
@FunctionNames({ "APPLY" })
|
@FunctionNames({ "APPLY" })
|
||||||
public class APPLY extends LispFunction {
|
public class APPLY extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import sexpression.AtSignExpression;
|
import sexpression.AtSignExpression;
|
||||||
|
@ -11,6 +8,9 @@ import sexpression.CommaExpression;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
class BackquoteEvaluator {
|
class BackquoteEvaluator {
|
||||||
|
|
||||||
private ArgumentValidator listValidator;
|
private ArgumentValidator listValidator;
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static function.builtin.cons.LIST.makeList;
|
|
||||||
import static function.builtin.special.LAMBDA.createFunction;
|
|
||||||
import static function.builtin.special.LAMBDA.isLambdaExpression;
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
import static table.FunctionTable.lookupFunction;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
|
@ -20,6 +12,14 @@ import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
import table.ExecutionContext;
|
import table.ExecutionContext;
|
||||||
|
|
||||||
|
import static function.builtin.cons.LIST.makeList;
|
||||||
|
import static function.builtin.special.LAMBDA.createFunction;
|
||||||
|
import static function.builtin.special.LAMBDA.isLambdaExpression;
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
import static table.FunctionTable.lookupFunction;
|
||||||
|
|
||||||
@FunctionNames({ "EVAL" })
|
@FunctionNames({ "EVAL" })
|
||||||
public class EVAL extends LispFunction {
|
public class EVAL extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import environment.RuntimeEnvironment;
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
|
@ -9,6 +7,8 @@ import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
@FunctionNames({ "EXIT" })
|
@FunctionNames({ "EXIT" })
|
||||||
public class EXIT extends LispFunction {
|
public class EXIT extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static function.builtin.APPLY.apply;
|
|
||||||
import static function.builtin.cons.LIST.makeList;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.APPLY.apply;
|
||||||
|
import static function.builtin.cons.LIST.makeList;
|
||||||
|
|
||||||
@FunctionNames({ "FUNCALL", "CALL" })
|
@FunctionNames({ "FUNCALL", "CALL" })
|
||||||
public class FUNCALL extends LispFunction {
|
public class FUNCALL extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
|
@ -9,6 +7,8 @@ import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
@FunctionNames({ "GENSYM" })
|
@FunctionNames({ "GENSYM" })
|
||||||
public class GENSYM extends LispFunction {
|
public class GENSYM extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
import static util.Path.getPathPrefix;
|
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import environment.RuntimeEnvironment;
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import error.LispWarning;
|
import error.LispWarning;
|
||||||
|
@ -21,6 +11,16 @@ import sexpression.Cons;
|
||||||
import sexpression.LispString;
|
import sexpression.LispString;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
import static util.Path.getPathPrefix;
|
||||||
|
|
||||||
@FunctionNames({ "LOAD" })
|
@FunctionNames({ "LOAD" })
|
||||||
public class LOAD extends LispFunction {
|
public class LOAD extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static table.FunctionTable.lookupFunction;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
|
@ -11,6 +9,8 @@ import sexpression.Symbol;
|
||||||
import table.ExecutionContext;
|
import table.ExecutionContext;
|
||||||
import table.SymbolTable;
|
import table.SymbolTable;
|
||||||
|
|
||||||
|
import static table.FunctionTable.lookupFunction;
|
||||||
|
|
||||||
@FunctionNames({ "SET" })
|
@FunctionNames({ "SET" })
|
||||||
public class SET extends LispFunction {
|
public class SET extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
import static table.FunctionTable.lookupFunction;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
|
@ -13,6 +10,9 @@ import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
import static table.FunctionTable.lookupFunction;
|
||||||
|
|
||||||
@FunctionNames({ "SYMBOL-FUNCTION" })
|
@FunctionNames({ "SYMBOL-FUNCTION" })
|
||||||
public class SYMBOL_FUNCTION extends LispFunction {
|
public class SYMBOL_FUNCTION extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package function.builtin.cons;
|
package function.builtin.cons;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static table.FunctionTable.lookupFunction;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static table.FunctionTable.lookupFunction;
|
||||||
|
|
||||||
@FunctionNames({ "APPEND" })
|
@FunctionNames({ "APPEND" })
|
||||||
public class APPEND extends LispFunction {
|
public class APPEND extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package function.builtin.cons;
|
package function.builtin.cons;
|
||||||
|
|
||||||
import static function.builtin.cons.LIST.makeList;
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static table.FunctionTable.lookupFunction;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
|
@ -14,6 +7,13 @@ import recursion.TailCall;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import static function.builtin.cons.LIST.makeList;
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static table.FunctionTable.lookupFunction;
|
||||||
|
|
||||||
@FunctionNames({ "LENGTH" })
|
@FunctionNames({ "LENGTH" })
|
||||||
public class LENGTH extends LispFunction {
|
public class LENGTH extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package function.builtin.cons;
|
package function.builtin.cons;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
@FunctionNames({ "LIST" })
|
@FunctionNames({ "LIST" })
|
||||||
public class LIST extends LispFunction {
|
public class LIST extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package function.builtin.math;
|
package function.builtin.math;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
|
@ -9,6 +7,8 @@ import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
@FunctionNames({ "/" })
|
@FunctionNames({ "/" })
|
||||||
public class DIVIDE extends LispFunction {
|
public class DIVIDE extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package function.builtin.math;
|
package function.builtin.math;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
@FunctionNames({ "-" })
|
@FunctionNames({ "-" })
|
||||||
public class MINUS extends LispFunction {
|
public class MINUS extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package function.builtin.math;
|
package function.builtin.math;
|
||||||
|
|
||||||
import static sexpression.LispNumber.ONE;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
|
|
||||||
|
import static sexpression.LispNumber.ONE;
|
||||||
|
|
||||||
@FunctionNames({ "*" })
|
@FunctionNames({ "*" })
|
||||||
public class MULTIPLY extends LispFunction {
|
public class MULTIPLY extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package function.builtin.math;
|
package function.builtin.math;
|
||||||
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import recursion.TailCall;
|
import recursion.TailCall;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
|
||||||
class MathFunction {
|
class MathFunction {
|
||||||
|
|
||||||
Function<LispNumber, LispNumber> singleValueOperation;
|
Function<LispNumber, LispNumber> singleValueOperation;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package function.builtin.math;
|
package function.builtin.math;
|
||||||
|
|
||||||
import static sexpression.LispNumber.ZERO;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
|
|
||||||
|
import static sexpression.LispNumber.ZERO;
|
||||||
|
|
||||||
@FunctionNames({ "+" })
|
@FunctionNames({ "+" })
|
||||||
public class PLUS extends LispFunction {
|
public class PLUS extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "ATOM", "ATOM?" })
|
@FunctionNames({ "ATOM", "ATOM?" })
|
||||||
public class ATOM extends LispFunction {
|
public class ATOM extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "EQ", "EQ?" })
|
@FunctionNames({ "EQ", "EQ?" })
|
||||||
public class EQ extends LispFunction {
|
public class EQ extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "EQUAL", "EQUAL?" })
|
@FunctionNames({ "EQUAL", "EQUAL?" })
|
||||||
public class EQUAL extends LispFunction {
|
public class EQUAL extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static function.builtin.GENSYM.GENSYM_PREFIX;
|
import function.ArgumentValidator;
|
||||||
import static sexpression.Nil.NIL;
|
import function.FunctionNames;
|
||||||
import static sexpression.Symbol.T;
|
import function.LispFunction;
|
||||||
|
import sexpression.Cons;
|
||||||
|
import sexpression.SExpression;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -10,11 +12,9 @@ import java.util.Map.Entry;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import static function.builtin.GENSYM.GENSYM_PREFIX;
|
||||||
import function.FunctionNames;
|
import static sexpression.Nil.NIL;
|
||||||
import function.LispFunction;
|
import static sexpression.Symbol.T;
|
||||||
import sexpression.Cons;
|
|
||||||
import sexpression.SExpression;
|
|
||||||
|
|
||||||
@FunctionNames({ "GENSYM-EQUAL", "GENSYM-EQUAL?" })
|
@FunctionNames({ "GENSYM-EQUAL", "GENSYM-EQUAL?" })
|
||||||
public class GENSYM_EQUAL extends LispFunction {
|
public class GENSYM_EQUAL extends LispFunction {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "LISTP", "LIST?" })
|
@FunctionNames({ "LISTP", "LIST?" })
|
||||||
public class LISTP extends LispFunction {
|
public class LISTP extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "NULL", "NULL?" })
|
@FunctionNames({ "NULL", "NULL?" })
|
||||||
public class NULL extends LispFunction {
|
public class NULL extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
|
@ -13,6 +8,11 @@ import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "=" })
|
@FunctionNames({ "=" })
|
||||||
public class NUMERIC_EQUAL extends LispFunction {
|
public class NUMERIC_EQUAL extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
|
@ -13,6 +8,11 @@ import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ ">" })
|
@FunctionNames({ ">" })
|
||||||
public class NUMERIC_GREATER extends LispFunction {
|
public class NUMERIC_GREATER extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package function.builtin.predicate;
|
package function.builtin.predicate;
|
||||||
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
|
@ -13,6 +8,11 @@ import sexpression.Cons;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "<" })
|
@FunctionNames({ "<" })
|
||||||
public class NUMERIC_LESS extends LispFunction {
|
public class NUMERIC_LESS extends LispFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -12,6 +7,11 @@ import recursion.TailCall;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "AND" })
|
@FunctionNames({ "AND" })
|
||||||
public class AND extends LispSpecialFunction {
|
public class AND extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static function.builtin.predicate.EQUAL.isEqual;
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -15,6 +8,13 @@ import sexpression.Cons;
|
||||||
import sexpression.Nil;
|
import sexpression.Nil;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static function.builtin.predicate.EQUAL.isEqual;
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
@FunctionNames({ "CASE" })
|
@FunctionNames({ "CASE" })
|
||||||
public class CASE extends LispSpecialFunction {
|
public class CASE extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -13,6 +8,11 @@ import sexpression.Cons;
|
||||||
import sexpression.Nil;
|
import sexpression.Nil;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
@FunctionNames({ "COND" })
|
@FunctionNames({ "COND" })
|
||||||
public class COND extends LispSpecialFunction {
|
public class COND extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.cons.LIST.makeList;
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
import static table.FunctionTable.defineFunction;
|
|
||||||
import static table.FunctionTable.isAlreadyDefined;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import environment.RuntimeEnvironment;
|
||||||
import error.LispWarning;
|
import error.LispWarning;
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
|
@ -14,6 +9,11 @@ import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import static function.builtin.cons.LIST.makeList;
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
import static table.FunctionTable.defineFunction;
|
||||||
|
import static table.FunctionTable.isAlreadyDefined;
|
||||||
|
|
||||||
public abstract class Define extends LispSpecialFunction {
|
public abstract class Define extends LispSpecialFunction {
|
||||||
|
|
||||||
private ArgumentValidator argumentValidator;
|
private ArgumentValidator argumentValidator;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
|
||||||
@FunctionNames({ "IF" })
|
@FunctionNames({ "IF" })
|
||||||
public class IF extends LispSpecialFunction {
|
public class IF extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.cons.LIST.makeList;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -11,6 +9,8 @@ import sexpression.LambdaExpression;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import static function.builtin.cons.LIST.makeList;
|
||||||
|
|
||||||
@FunctionNames({ "LAMBDA", "Λ" })
|
@FunctionNames({ "LAMBDA", "Λ" })
|
||||||
public class LAMBDA extends LispSpecialFunction {
|
public class LAMBDA extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -12,6 +9,9 @@ import sexpression.Symbol;
|
||||||
import table.ExecutionContext;
|
import table.ExecutionContext;
|
||||||
import table.SymbolTable;
|
import table.SymbolTable;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
@FunctionNames({ "LET" })
|
@FunctionNames({ "LET" })
|
||||||
public class LET extends LispSpecialFunction {
|
public class LET extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -11,6 +7,10 @@ import recursion.TailCall;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
|
||||||
@FunctionNames({ "OR" })
|
@FunctionNames({ "OR" })
|
||||||
public class OR extends LispSpecialFunction {
|
public class OR extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -12,6 +7,11 @@ import recursion.TailCall;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
@FunctionNames({ "PROGN", "BEGIN" })
|
@FunctionNames({ "PROGN", "BEGIN" })
|
||||||
public class PROGN extends LispSpecialFunction {
|
public class PROGN extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.evaluateFunctionArgumentList;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
|
@ -10,6 +8,8 @@ import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import table.ExecutionContext;
|
import table.ExecutionContext;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.evaluateFunctionArgumentList;
|
||||||
|
|
||||||
@FunctionNames({ "RECUR" })
|
@FunctionNames({ "RECUR" })
|
||||||
public class RECUR extends LispSpecialFunction {
|
public class RECUR extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package function.builtin.special;
|
package function.builtin.special;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
import static function.builtin.SET.set;
|
|
||||||
import static function.builtin.cons.LIST.makeList;
|
|
||||||
|
|
||||||
import function.ArgumentValidator;
|
import function.ArgumentValidator;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispSpecialFunction;
|
import function.LispSpecialFunction;
|
||||||
|
@ -11,6 +7,10 @@ import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
import static function.builtin.SET.set;
|
||||||
|
import static function.builtin.cons.LIST.makeList;
|
||||||
|
|
||||||
@FunctionNames({ "SETQ" })
|
@FunctionNames({ "SETQ" })
|
||||||
public class SETQ extends LispSpecialFunction {
|
public class SETQ extends LispSpecialFunction {
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package interpreter;
|
package interpreter;
|
||||||
|
|
||||||
import static function.builtin.EVAL.eval;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import environment.RuntimeEnvironment;
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import parser.LispParser;
|
import parser.LispParser;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.eval;
|
||||||
|
|
||||||
public class LispInterpreter {
|
public class LispInterpreter {
|
||||||
|
|
||||||
protected RuntimeEnvironment environment;
|
protected RuntimeEnvironment environment;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package interpreter;
|
package interpreter;
|
||||||
|
|
||||||
import static util.Path.getPathPrefix;
|
import environment.RuntimeEnvironment;
|
||||||
|
import error.CriticalLispException;
|
||||||
|
import error.ErrorManager;
|
||||||
|
import interpreter.LispInterpreter.LanguageFile;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -10,10 +13,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import static util.Path.getPathPrefix;
|
||||||
import error.CriticalLispException;
|
|
||||||
import error.ErrorManager;
|
|
||||||
import interpreter.LispInterpreter.LanguageFile;
|
|
||||||
|
|
||||||
public class LispInterpreterBuilderImpl implements LispInterpreterBuilder {
|
public class LispInterpreterBuilderImpl implements LispInterpreterBuilder {
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package parser;
|
package parser;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import error.LispException;
|
import error.LispException;
|
||||||
import scanner.LispScanner;
|
import scanner.LispScanner;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import token.Eof;
|
import token.Eof;
|
||||||
import token.Token;
|
import token.Token;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a stream of bytes into internal representations of Lisp s-expressions.
|
* Converts a stream of bytes into internal representations of Lisp s-expressions.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,14 +16,10 @@ public interface TailCall<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
default T invoke() {
|
default T invoke() {
|
||||||
// @formatter:off
|
|
||||||
|
|
||||||
return Stream.iterate(this, TailCall::apply)
|
return Stream.iterate(this, TailCall::apply)
|
||||||
.filter(TailCall::isComplete)
|
.filter(TailCall::isComplete)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get()
|
.get()
|
||||||
.result();
|
.result();
|
||||||
|
|
||||||
// @formatter:on
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package scanner;
|
package scanner;
|
||||||
|
|
||||||
|
import stream.SafeInputStream;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import static util.Characters.BACKSLASH;
|
import static util.Characters.BACKSLASH;
|
||||||
import static util.Characters.DOUBLE_QUOTE;
|
import static util.Characters.DOUBLE_QUOTE;
|
||||||
import static util.Characters.EOF;
|
import static util.Characters.EOF;
|
||||||
import static util.Characters.NEWLINE;
|
import static util.Characters.NEWLINE;
|
||||||
import static util.Characters.SEMICOLON;
|
import static util.Characters.SEMICOLON;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import stream.SafeInputStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes Lisp comments from an input stream.
|
* Removes Lisp comments from an input stream.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package scanner;
|
package scanner;
|
||||||
|
|
||||||
|
import error.LineColumnException;
|
||||||
|
import file.FilePosition;
|
||||||
|
import file.FilePositionTracker;
|
||||||
|
import token.Token;
|
||||||
|
import token.TokenFactory;
|
||||||
|
import token.TokenFactoryImpl;
|
||||||
|
import util.Characters;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static java.lang.Character.isDigit;
|
import static java.lang.Character.isDigit;
|
||||||
import static java.lang.Character.isWhitespace;
|
import static java.lang.Character.isWhitespace;
|
||||||
import static util.Characters.BACKSLASH;
|
import static util.Characters.BACKSLASH;
|
||||||
|
@ -9,17 +20,6 @@ import static util.Characters.NEWLINE;
|
||||||
import static util.Characters.isLegalIdentifierCharacter;
|
import static util.Characters.isLegalIdentifierCharacter;
|
||||||
import static util.Characters.isNumberPrefix;
|
import static util.Characters.isNumberPrefix;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import error.LineColumnException;
|
|
||||||
import file.FilePosition;
|
|
||||||
import file.FilePositionTracker;
|
|
||||||
import token.Token;
|
|
||||||
import token.TokenFactory;
|
|
||||||
import token.TokenFactoryImpl;
|
|
||||||
import util.Characters;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a stream of bytes into a stream of Lisp tokens.
|
* Converts a stream of bytes into a stream of Lisp tokens.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package sexpression;
|
package sexpression;
|
||||||
|
|
||||||
|
import recursion.TailCall;
|
||||||
|
|
||||||
import static recursion.TailCalls.done;
|
import static recursion.TailCalls.done;
|
||||||
import static recursion.TailCalls.tailCall;
|
import static recursion.TailCalls.tailCall;
|
||||||
|
|
||||||
import recursion.TailCall;
|
|
||||||
|
|
||||||
@DisplayName("list")
|
@DisplayName("list")
|
||||||
public class Cons extends SExpression {
|
public class Cons extends SExpression {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package sexpression;
|
package sexpression;
|
||||||
|
|
||||||
import static java.text.MessageFormat.format;
|
import error.LispException;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
import error.LispException;
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
@DisplayName("number")
|
@DisplayName("number")
|
||||||
public class LispNumber extends Atom {
|
public class LispNumber extends Atom {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package stream;
|
package stream;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
public class SafeInputStream {
|
public class SafeInputStream {
|
||||||
|
|
||||||
private InputStreamReader underlyingStream;
|
private InputStreamReader underlyingStream;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package stream;
|
package stream;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import error.CriticalLispException;
|
import error.CriticalLispException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class UncheckedIOException extends CriticalLispException {
|
public class UncheckedIOException extends CriticalLispException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package table;
|
package table;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
public class ExecutionContext {
|
public class ExecutionContext {
|
||||||
|
|
||||||
private static ExecutionContext uniqueInstance = new ExecutionContext();
|
private static ExecutionContext uniqueInstance = new ExecutionContext();
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package table;
|
package table;
|
||||||
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import error.CriticalLispException;
|
import error.CriticalLispException;
|
||||||
import function.FunctionNames;
|
import function.FunctionNames;
|
||||||
import function.LispFunction;
|
import function.LispFunction;
|
||||||
|
@ -58,6 +51,13 @@ import function.builtin.special.QUOTE;
|
||||||
import function.builtin.special.RECUR;
|
import function.builtin.special.RECUR;
|
||||||
import function.builtin.special.SETQ;
|
import function.builtin.special.SETQ;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
public class FunctionTable {
|
public class FunctionTable {
|
||||||
|
|
||||||
private static Set<Class<? extends LispFunction>> allBuiltIns = new HashSet<>();
|
private static Set<Class<? extends LispFunction>> allBuiltIns = new HashSet<>();
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package table;
|
package table;
|
||||||
|
|
||||||
import static function.builtin.cons.APPEND.append;
|
import sexpression.Cons;
|
||||||
import static function.builtin.cons.LIST.makeList;
|
import sexpression.SExpression;
|
||||||
import static sexpression.Nil.NIL;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import sexpression.Cons;
|
import static function.builtin.cons.APPEND.append;
|
||||||
import sexpression.SExpression;
|
import static function.builtin.cons.LIST.makeList;
|
||||||
import sexpression.Symbol;
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
public class SymbolTable {
|
public class SymbolTable {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package terminal;
|
package terminal;
|
||||||
|
|
||||||
|
import stream.SafeInputStream;
|
||||||
|
|
||||||
import static java.lang.Character.isDigit;
|
import static java.lang.Character.isDigit;
|
||||||
import static util.Characters.EOF;
|
import static util.Characters.EOF;
|
||||||
import static util.Characters.LEFT_SQUARE_BRACKET;
|
import static util.Characters.LEFT_SQUARE_BRACKET;
|
||||||
import static util.Characters.UNICODE_ESCAPE;
|
import static util.Characters.UNICODE_ESCAPE;
|
||||||
|
|
||||||
import stream.SafeInputStream;
|
|
||||||
|
|
||||||
class ControlSequenceHandler {
|
class ControlSequenceHandler {
|
||||||
|
|
||||||
public static final boolean isEscape(char c) {
|
public static final boolean isEscape(char c) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package terminal;
|
package terminal;
|
||||||
|
|
||||||
import static terminal.SelectGraphicRendition.SGR_COMMAND;
|
import terminal.ControlSequence.NullControlSequence;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import terminal.ControlSequence.NullControlSequence;
|
import static terminal.SelectGraphicRendition.SGR_COMMAND;
|
||||||
|
|
||||||
public class ControlSequenceLookup {
|
public class ControlSequenceLookup {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
package terminal;
|
package terminal;
|
||||||
|
|
||||||
|
import com.googlecode.lanterna.TerminalPosition;
|
||||||
|
import com.googlecode.lanterna.TerminalSize;
|
||||||
|
import com.googlecode.lanterna.input.KeyStroke;
|
||||||
|
import com.googlecode.lanterna.input.KeyType;
|
||||||
|
import com.googlecode.lanterna.terminal.IOSafeTerminal;
|
||||||
|
import stream.SafeInputStream;
|
||||||
|
import stream.SafeOutputStream;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import static com.googlecode.lanterna.input.KeyType.ArrowDown;
|
import static com.googlecode.lanterna.input.KeyType.ArrowDown;
|
||||||
import static com.googlecode.lanterna.input.KeyType.ArrowLeft;
|
import static com.googlecode.lanterna.input.KeyType.ArrowLeft;
|
||||||
import static com.googlecode.lanterna.input.KeyType.ArrowRight;
|
import static com.googlecode.lanterna.input.KeyType.ArrowRight;
|
||||||
|
@ -12,19 +24,6 @@ import static terminal.ControlSequenceHandler.isEscape;
|
||||||
import static util.Characters.EOF;
|
import static util.Characters.EOF;
|
||||||
import static util.Characters.UNICODE_NULL;
|
import static util.Characters.UNICODE_NULL;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
import com.googlecode.lanterna.TerminalPosition;
|
|
||||||
import com.googlecode.lanterna.TerminalSize;
|
|
||||||
import com.googlecode.lanterna.input.KeyStroke;
|
|
||||||
import com.googlecode.lanterna.input.KeyType;
|
|
||||||
import com.googlecode.lanterna.terminal.IOSafeTerminal;
|
|
||||||
|
|
||||||
import stream.SafeInputStream;
|
|
||||||
import stream.SafeOutputStream;
|
|
||||||
|
|
||||||
public class LispTerminal {
|
public class LispTerminal {
|
||||||
|
|
||||||
public static final char END_OF_SEGMENT = UNICODE_NULL;
|
public static final char END_OF_SEGMENT = UNICODE_NULL;
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package terminal;
|
package terminal;
|
||||||
|
|
||||||
|
import com.googlecode.lanterna.terminal.IOSafeTerminal;
|
||||||
|
import stream.UncheckedIOException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PipedInputStream;
|
import java.io.PipedInputStream;
|
||||||
import java.io.PipedOutputStream;
|
import java.io.PipedOutputStream;
|
||||||
|
|
||||||
import com.googlecode.lanterna.terminal.IOSafeTerminal;
|
|
||||||
|
|
||||||
import stream.UncheckedIOException;
|
|
||||||
|
|
||||||
public class TerminalConfiguration {
|
public class TerminalConfiguration {
|
||||||
|
|
||||||
private PipedOutputStream inputWriter;
|
private PipedOutputStream inputWriter;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.AtSignExpression;
|
import sexpression.AtSignExpression;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class AtSign extends Token {
|
public class AtSign extends Token {
|
||||||
|
|
||||||
public AtSign(String text, FilePosition position) {
|
public AtSign(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.BackquoteExpression;
|
import sexpression.BackquoteExpression;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class Backquote extends Token {
|
public class Backquote extends Token {
|
||||||
|
|
||||||
public Backquote(String text, FilePosition position) {
|
public Backquote(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.CommaExpression;
|
import sexpression.CommaExpression;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class Comma extends Token {
|
public class Comma extends Token {
|
||||||
|
|
||||||
public Comma(String text, FilePosition position) {
|
public Comma(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import error.LineColumnException;
|
import error.LineColumnException;
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class Eof extends Token {
|
public class Eof extends Token {
|
||||||
|
|
||||||
public Eof(String text, FilePosition position) {
|
public Eof(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class Identifier extends Token {
|
public class Identifier extends Token {
|
||||||
|
|
||||||
public Identifier(String text, FilePosition position) {
|
public Identifier(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class LeftParenthesis extends Token {
|
public class LeftParenthesis extends Token {
|
||||||
|
|
||||||
public LeftParenthesis(String text, FilePosition position) {
|
public LeftParenthesis(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class Number extends Token {
|
public class Number extends Token {
|
||||||
|
|
||||||
public Number(String text, FilePosition position) {
|
public Number(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
public class QuoteMark extends Token {
|
public class QuoteMark extends Token {
|
||||||
|
|
||||||
public QuoteMark(String text, FilePosition position) {
|
public QuoteMark(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import sexpression.LispString;
|
import sexpression.LispString;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class QuotedString extends Token {
|
public class QuotedString extends Token {
|
||||||
|
|
||||||
public QuotedString(String text, FilePosition position) {
|
public QuotedString(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import static recursion.TailCalls.done;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import error.LineColumnException;
|
import error.LineColumnException;
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import recursion.TailCall;
|
import recursion.TailCall;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import static recursion.TailCalls.done;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
public class RightParenthesis extends Token {
|
public class RightParenthesis extends Token {
|
||||||
|
|
||||||
public RightParenthesis(String text, FilePosition position) {
|
public RightParenthesis(String text, FilePosition position) {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import static recursion.TailCalls.tailCall;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
import recursion.TailCall;
|
import recursion.TailCall;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
|
||||||
public abstract class Token {
|
public abstract class Token {
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
|
|
||||||
import error.CriticalLineColumnException;
|
import error.CriticalLineColumnException;
|
||||||
import error.LineColumnException;
|
import error.LineColumnException;
|
||||||
import file.FilePosition;
|
import file.FilePosition;
|
||||||
|
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
public interface TokenFactory {
|
public interface TokenFactory {
|
||||||
|
|
||||||
Token createToken(String text, FilePosition position);
|
Token createToken(String text, FilePosition position);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package token;
|
package token;
|
||||||
|
|
||||||
|
import file.FilePosition;
|
||||||
|
|
||||||
import static java.lang.Character.isDigit;
|
import static java.lang.Character.isDigit;
|
||||||
import static util.Characters.AT_SIGN;
|
import static util.Characters.AT_SIGN;
|
||||||
import static util.Characters.BACKQUOTE;
|
import static util.Characters.BACKQUOTE;
|
||||||
|
@ -11,8 +13,6 @@ import static util.Characters.SINGLE_QUOTE;
|
||||||
import static util.Characters.isLegalIdentifierCharacter;
|
import static util.Characters.isLegalIdentifierCharacter;
|
||||||
import static util.Characters.isNumberPrefix;
|
import static util.Characters.isNumberPrefix;
|
||||||
|
|
||||||
import file.FilePosition;
|
|
||||||
|
|
||||||
public class TokenFactoryImpl implements TokenFactory {
|
public class TokenFactoryImpl implements TokenFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package acceptance;
|
package acceptance;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import fitnesse.junit.FitNesseRunner;
|
import fitnesse.junit.FitNesseRunner;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@RunWith(FitNesseRunner.class)
|
@RunWith(FitNesseRunner.class)
|
||||||
@FitNesseRunner.Suite("TranscendentalLisp")
|
@FitNesseRunner.Suite("TranscendentalLisp")
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package acceptance.fixture;
|
package acceptance.fixture;
|
||||||
|
|
||||||
import static application.LispMain.LANGUAGE_FILE_NAMES;
|
import environment.RuntimeEnvironment;
|
||||||
import static table.FunctionTable.resetFunctionTable;
|
import interpreter.LispInterpreter;
|
||||||
import static util.Path.getPathPrefix;
|
import interpreter.LispInterpreterBuilder;
|
||||||
|
import interpreter.LispInterpreterBuilderImpl;
|
||||||
|
import table.ExecutionContext;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -10,11 +12,9 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import static application.LispMain.LANGUAGE_FILE_NAMES;
|
||||||
import interpreter.LispInterpreter;
|
import static table.FunctionTable.resetFunctionTable;
|
||||||
import interpreter.LispInterpreterBuilder;
|
import static util.Path.getPathPrefix;
|
||||||
import interpreter.LispInterpreterBuilderImpl;
|
|
||||||
import table.ExecutionContext;
|
|
||||||
|
|
||||||
public class LispInterpreterFixture {
|
public class LispInterpreterFixture {
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
package application;
|
package application;
|
||||||
|
|
||||||
import static com.googlecode.lanterna.input.KeyType.Enter;
|
import com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal;
|
||||||
import static java.text.MessageFormat.format;
|
import environment.RuntimeEnvironment;
|
||||||
import static application.LispMain.ANSI_GREEN;
|
import interpreter.LispInterpreterBuilderImpl;
|
||||||
import static application.LispMain.ANSI_PURPLE;
|
|
||||||
import static application.LispMain.ANSI_RESET;
|
|
||||||
import static application.LispMain.GREETING;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.PipedInputStream;
|
|
||||||
import java.io.PipedOutputStream;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
|
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
|
||||||
import org.junit.contrib.java.lang.system.SystemErrRule;
|
import org.junit.contrib.java.lang.system.SystemErrRule;
|
||||||
import org.junit.contrib.java.lang.system.SystemOutRule;
|
import org.junit.contrib.java.lang.system.SystemOutRule;
|
||||||
|
|
||||||
import com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
|
||||||
import interpreter.LispInterpreterBuilderImpl;
|
|
||||||
import terminal.TerminalConfiguration;
|
import terminal.TerminalConfiguration;
|
||||||
import terminal.VirtualTerminalInteractor;
|
import terminal.VirtualTerminalInteractor;
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
|
import java.io.PipedInputStream;
|
||||||
|
import java.io.PipedOutputStream;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
|
import static application.LispMain.ANSI_GREEN;
|
||||||
|
import static application.LispMain.ANSI_PURPLE;
|
||||||
|
import static application.LispMain.ANSI_RESET;
|
||||||
|
import static application.LispMain.GREETING;
|
||||||
|
import static com.googlecode.lanterna.input.KeyType.Enter;
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class MainTest extends SymbolAndFunctionCleaner {
|
public class MainTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
private RuntimeEnvironment environment;
|
private RuntimeEnvironment environment;
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package environment;
|
package environment;
|
||||||
|
|
||||||
|
import error.ErrorManager;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import error.ErrorManager;
|
|
||||||
|
|
||||||
public class RuntimeEnvironmentTest {
|
public class RuntimeEnvironmentTest {
|
||||||
|
|
||||||
private static final String TERMINATED_SUCCESSFULLY = "TERMINATED_SUCCESSFULLY";
|
private static final String TERMINATED_SUCCESSFULLY = "TERMINATED_SUCCESSFULLY";
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
package error;
|
package error;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.CRITICAL;
|
import environment.RuntimeEnvironment;
|
||||||
import static error.ErrorManager.Severity.ERROR;
|
import error.ErrorManager.Severity;
|
||||||
import static error.ErrorManager.Severity.WARNING;
|
import org.junit.After;
|
||||||
import static org.junit.Assert.assertFalse;
|
import org.junit.Before;
|
||||||
import static org.junit.Assert.assertTrue;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.junit.After;
|
import static error.ErrorManager.Severity.CRITICAL;
|
||||||
import org.junit.Before;
|
import static error.ErrorManager.Severity.ERROR;
|
||||||
import org.junit.Test;
|
import static error.ErrorManager.Severity.WARNING;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import environment.RuntimeEnvironment;
|
import static org.junit.Assert.assertTrue;
|
||||||
import error.ErrorManager.Severity;
|
|
||||||
|
|
||||||
public class ErrorManagerTest {
|
public class ErrorManagerTest {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package file;
|
package file;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class FilePositionTrackerTest {
|
public class FilePositionTrackerTest {
|
||||||
|
|
||||||
public static final String FILE_NAME = "testFile";
|
public static final String FILE_NAME = "testFile";
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
package function;
|
package function;
|
||||||
|
|
||||||
|
import function.ArgumentValidator.BadArgumentTypeException;
|
||||||
|
import function.ArgumentValidator.DottedArgumentListException;
|
||||||
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import sexpression.Cons;
|
||||||
|
import sexpression.LispString;
|
||||||
|
import sexpression.Nil;
|
||||||
|
import sexpression.SExpression;
|
||||||
|
import sexpression.Symbol;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.ERROR;
|
import static error.ErrorManager.Severity.ERROR;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -7,19 +19,6 @@ import static org.junit.Assert.assertTrue;
|
||||||
import static sexpression.Nil.NIL;
|
import static sexpression.Nil.NIL;
|
||||||
import static sexpression.Symbol.T;
|
import static sexpression.Symbol.T;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.BadArgumentTypeException;
|
|
||||||
import function.ArgumentValidator.DottedArgumentListException;
|
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
|
||||||
import sexpression.Cons;
|
|
||||||
import sexpression.LispString;
|
|
||||||
import sexpression.Nil;
|
|
||||||
import sexpression.SExpression;
|
|
||||||
import sexpression.Symbol;
|
|
||||||
|
|
||||||
public class ArgumentValidatorTest {
|
public class ArgumentValidatorTest {
|
||||||
|
|
||||||
private ArgumentValidator validator;
|
private ArgumentValidator validator;
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package function;
|
package function;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class LispFunctionTest {
|
public class LispFunctionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package function;
|
package function;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
public class LispSpecialFunctionTest {
|
public class LispSpecialFunctionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
package function;
|
package function;
|
||||||
|
|
||||||
|
import error.ErrorManager;
|
||||||
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import function.UserDefinedFunction.IllegalKeywordRestPositionException;
|
||||||
|
import org.junit.Test;
|
||||||
|
import sexpression.Cons;
|
||||||
|
import sexpression.LispNumber;
|
||||||
|
import sexpression.SExpression;
|
||||||
|
import sexpression.Symbol;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static sexpression.Nil.NIL;
|
import static sexpression.Nil.NIL;
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import error.ErrorManager;
|
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
|
||||||
import function.UserDefinedFunction.IllegalKeywordRestPositionException;
|
|
||||||
import sexpression.Cons;
|
|
||||||
import sexpression.LispNumber;
|
|
||||||
import sexpression.SExpression;
|
|
||||||
import sexpression.Symbol;
|
|
||||||
|
|
||||||
public class UserDefinedFunctionTest {
|
public class UserDefinedFunctionTest {
|
||||||
|
|
||||||
private static final String FUNCTION_NAME = "TEST";
|
private static final String FUNCTION_NAME = "TEST";
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static function.builtin.APPLY.apply;
|
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
|
||||||
import static testutil.TestUtilities.evaluateString;
|
|
||||||
import static testutil.TestUtilities.parseString;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.BadArgumentTypeException;
|
import function.ArgumentValidator.BadArgumentTypeException;
|
||||||
import function.ArgumentValidator.DottedArgumentListException;
|
import function.ArgumentValidator.DottedArgumentListException;
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
import function.builtin.EVAL.UndefinedFunctionException;
|
import function.builtin.EVAL.UndefinedFunctionException;
|
||||||
|
import org.junit.Test;
|
||||||
import sexpression.Cons;
|
import sexpression.Cons;
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
|
import static function.builtin.APPLY.apply;
|
||||||
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
import static testutil.TestUtilities.parseString;
|
||||||
|
|
||||||
public class APPLYTest extends SymbolAndFunctionCleaner {
|
public class APPLYTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static sexpression.Symbol.T;
|
|
||||||
import static testutil.TestUtilities.assertIsErrorWithMessage;
|
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
|
||||||
import static testutil.TestUtilities.makeList;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.DottedArgumentListException;
|
import function.ArgumentValidator.DottedArgumentListException;
|
||||||
import function.builtin.BackquoteEvaluator.AtSignNotInCommaException;
|
import function.builtin.BackquoteEvaluator.AtSignNotInCommaException;
|
||||||
import function.builtin.BackquoteEvaluator.AtSignNotListException;
|
import function.builtin.BackquoteEvaluator.AtSignNotListException;
|
||||||
import function.builtin.BackquoteEvaluator.NestedAtSignException;
|
import function.builtin.BackquoteEvaluator.NestedAtSignException;
|
||||||
import function.builtin.BackquoteEvaluator.NestedCommaException;
|
import function.builtin.BackquoteEvaluator.NestedCommaException;
|
||||||
|
import org.junit.Test;
|
||||||
import sexpression.AtSignExpression;
|
import sexpression.AtSignExpression;
|
||||||
import sexpression.BackquoteExpression;
|
import sexpression.BackquoteExpression;
|
||||||
import sexpression.CommaExpression;
|
import sexpression.CommaExpression;
|
||||||
|
@ -22,6 +15,12 @@ import sexpression.LispString;
|
||||||
import sexpression.SExpression;
|
import sexpression.SExpression;
|
||||||
import sexpression.Symbol;
|
import sexpression.Symbol;
|
||||||
|
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static sexpression.Symbol.T;
|
||||||
|
import static testutil.TestUtilities.assertIsErrorWithMessage;
|
||||||
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
|
import static testutil.TestUtilities.makeList;
|
||||||
|
|
||||||
public class BackquoteEvaluatorTest {
|
public class BackquoteEvaluatorTest {
|
||||||
|
|
||||||
private BackquoteEvaluator createBackquoteEvaluator(SExpression expression) {
|
private BackquoteEvaluator createBackquoteEvaluator(SExpression expression) {
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static function.builtin.EVAL.lookupSymbol;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import static sexpression.Nil.NIL;
|
|
||||||
import static testutil.TestUtilities.assertIsErrorWithMessage;
|
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
|
||||||
import static testutil.TestUtilities.evaluateString;
|
|
||||||
import static testutil.TestUtilities.parseString;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.DottedArgumentListException;
|
import function.ArgumentValidator.DottedArgumentListException;
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
@ -20,8 +9,18 @@ import function.builtin.EVAL.UndefinedSymbolException;
|
||||||
import function.builtin.EVAL.UnmatchedAtSignException;
|
import function.builtin.EVAL.UnmatchedAtSignException;
|
||||||
import function.builtin.EVAL.UnmatchedCommaException;
|
import function.builtin.EVAL.UnmatchedCommaException;
|
||||||
import function.builtin.special.RECUR.RecurNotInTailPositionException;
|
import function.builtin.special.RECUR.RecurNotInTailPositionException;
|
||||||
|
import org.junit.Test;
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
|
import static function.builtin.EVAL.lookupSymbol;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
import static sexpression.Nil.NIL;
|
||||||
|
import static testutil.TestUtilities.assertIsErrorWithMessage;
|
||||||
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
import static testutil.TestUtilities.parseString;
|
||||||
|
|
||||||
public class EVALTest extends SymbolAndFunctionCleaner {
|
public class EVALTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import environment.RuntimeEnvironment;
|
||||||
import static org.junit.Assert.assertTrue;
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
import static testutil.TestUtilities.evaluateString;
|
import org.junit.Test;
|
||||||
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import environment.RuntimeEnvironment;
|
import static testutil.TestUtilities.evaluateString;
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
|
||||||
|
|
||||||
public class EXITTest extends SymbolAndFunctionCleaner {
|
public class EXITTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
|
import org.junit.Test;
|
||||||
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
import static testutil.TestUtilities.evaluateString;
|
import static testutil.TestUtilities.evaluateString;
|
||||||
import static testutil.TestUtilities.parseString;
|
import static testutil.TestUtilities.parseString;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
|
||||||
|
|
||||||
public class FUNCALLTest extends SymbolAndFunctionCleaner {
|
public class FUNCALLTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import org.junit.Test;
|
||||||
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
import token.TokenFactory.BadCharacterException;
|
||||||
|
|
||||||
import static function.builtin.GENSYM.GENSYM_PREFIX;
|
import static function.builtin.GENSYM.GENSYM_PREFIX;
|
||||||
import static testutil.TestUtilities.assertSExpressionsDoNotMatch;
|
import static testutil.TestUtilities.assertSExpressionsDoNotMatch;
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
import static testutil.TestUtilities.evaluateString;
|
import static testutil.TestUtilities.evaluateString;
|
||||||
import static testutil.TypeAssertions.assertSymbol;
|
import static testutil.TypeAssertions.assertSymbol;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
|
||||||
import token.TokenFactory.BadCharacterException;
|
|
||||||
|
|
||||||
public class GENSYMTest extends SymbolAndFunctionCleaner {
|
public class GENSYMTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static testutil.TestUtilities.evaluateString;
|
|
||||||
import static testutil.TypeAssertions.assertNil;
|
|
||||||
import static testutil.TypeAssertions.assertT;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import environment.RuntimeEnvironment;
|
||||||
import error.ErrorManager;
|
import error.ErrorManager;
|
||||||
import function.ArgumentValidator.BadArgumentTypeException;
|
import function.ArgumentValidator.BadArgumentTypeException;
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import org.junit.Test;
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
import static testutil.TypeAssertions.assertNil;
|
||||||
|
import static testutil.TypeAssertions.assertT;
|
||||||
|
|
||||||
public class LOADTest extends SymbolAndFunctionCleaner {
|
public class LOADTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
private ByteArrayOutputStream outputStream;
|
private ByteArrayOutputStream outputStream;
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static java.text.MessageFormat.format;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static testutil.TestUtilities.evaluateString;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import environment.RuntimeEnvironment;
|
import environment.RuntimeEnvironment;
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import org.junit.Test;
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
|
||||||
public class PRINTTest extends SymbolAndFunctionCleaner {
|
public class PRINTTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
private RuntimeEnvironment environment;
|
private RuntimeEnvironment environment;
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
|
||||||
import static testutil.TestUtilities.evaluateString;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.BadArgumentTypeException;
|
import function.ArgumentValidator.BadArgumentTypeException;
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
import function.builtin.EVAL.UndefinedSymbolException;
|
import function.builtin.EVAL.UndefinedSymbolException;
|
||||||
|
import org.junit.Test;
|
||||||
import sexpression.LispNumber;
|
import sexpression.LispNumber;
|
||||||
import table.SymbolTable;
|
import table.SymbolTable;
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
|
||||||
public class SETTest extends SymbolAndFunctionCleaner {
|
public class SETTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import org.junit.Test;
|
||||||
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
import static testutil.TestUtilities.evaluateString;
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
|
||||||
|
|
||||||
public class SYMBOLSTest extends SymbolAndFunctionCleaner {
|
public class SYMBOLSTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
package function.builtin;
|
package function.builtin;
|
||||||
|
|
||||||
|
import function.ArgumentValidator.BadArgumentTypeException;
|
||||||
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import function.builtin.SYMBOL_FUNCTION.UndefinedSymbolFunctionException;
|
||||||
|
import org.junit.Test;
|
||||||
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
import static error.ErrorManager.Severity.ERROR;
|
import static error.ErrorManager.Severity.ERROR;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -7,14 +14,6 @@ import static org.junit.Assert.assertTrue;
|
||||||
import static sexpression.Nil.NIL;
|
import static sexpression.Nil.NIL;
|
||||||
import static testutil.TestUtilities.evaluateString;
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.BadArgumentTypeException;
|
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
|
||||||
import function.builtin.SYMBOL_FUNCTION.UndefinedSymbolFunctionException;
|
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
|
||||||
|
|
||||||
public class SYMBOL_FUNCTIONTest extends SymbolAndFunctionCleaner {
|
public class SYMBOL_FUNCTIONTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package function.builtin.cons;
|
package function.builtin.cons;
|
||||||
|
|
||||||
import static testutil.TestUtilities.assertSExpressionsMatch;
|
|
||||||
import static testutil.TestUtilities.evaluateString;
|
|
||||||
import static testutil.TestUtilities.parseString;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import function.ArgumentValidator.BadArgumentTypeException;
|
import function.ArgumentValidator.BadArgumentTypeException;
|
||||||
import function.ArgumentValidator.DottedArgumentListException;
|
import function.ArgumentValidator.DottedArgumentListException;
|
||||||
import function.ArgumentValidator.TooFewArgumentsException;
|
import function.ArgumentValidator.TooFewArgumentsException;
|
||||||
import function.ArgumentValidator.TooManyArgumentsException;
|
import function.ArgumentValidator.TooManyArgumentsException;
|
||||||
|
import org.junit.Test;
|
||||||
import testutil.SymbolAndFunctionCleaner;
|
import testutil.SymbolAndFunctionCleaner;
|
||||||
|
|
||||||
|
import static testutil.TestUtilities.assertSExpressionsMatch;
|
||||||
|
import static testutil.TestUtilities.evaluateString;
|
||||||
|
import static testutil.TestUtilities.parseString;
|
||||||
|
|
||||||
public class APPENDTest extends SymbolAndFunctionCleaner {
|
public class APPENDTest extends SymbolAndFunctionCleaner {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue