58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
|
namespace KumiScript.Interpreter
|
||
|
{
|
||
|
public class NilExpression : ListExpression
|
||
|
{
|
||
|
private static NilExpression? _instance;
|
||
|
private NilExpression()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public static NilExpression GetInstance()
|
||
|
{
|
||
|
if (_instance is null)
|
||
|
_instance = new NilExpression();
|
||
|
|
||
|
return _instance;
|
||
|
}
|
||
|
|
||
|
public override Expression Car()
|
||
|
{
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public override ListExpression Cdr()
|
||
|
{
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public override ProperListExpression Cons(Expression expr)
|
||
|
{
|
||
|
return new ProperListExpression(new List<Expression> {expr});
|
||
|
}
|
||
|
|
||
|
public override bool Equals(Expression expr)
|
||
|
{
|
||
|
return expr is NilExpression;
|
||
|
}
|
||
|
|
||
|
public override Expression Eval(Environment env)
|
||
|
{
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public override List<Expression> EvalMembers(Environment env)
|
||
|
{
|
||
|
return new List<Expression>();
|
||
|
}
|
||
|
|
||
|
public override List<Expression> GetMembers()
|
||
|
{
|
||
|
return new List<Expression>();
|
||
|
}
|
||
|
|
||
|
public override string ToString()
|
||
|
{
|
||
|
return "null";
|
||
|
}
|
||
|
}
|
||
|
}
|