35 lines
No EOL
764 B
C#
35 lines
No EOL
764 B
C#
namespace KumiScript.Interpreter
|
|
{
|
|
public class SymbolExpression : Expression
|
|
{
|
|
readonly Symbol _value;
|
|
public SymbolExpression(Symbol s)
|
|
{
|
|
_value = s;
|
|
}
|
|
|
|
public override bool Equals(Expression expr)
|
|
{
|
|
SymbolExpression? sy = expr as SymbolExpression;
|
|
if (sy is null)
|
|
return false;
|
|
|
|
return _value.Equals(sy._value);
|
|
}
|
|
|
|
public override Expression Eval(Environment env)
|
|
{
|
|
return env.Lookup(_value);
|
|
}
|
|
|
|
public Symbol GetSymbol()
|
|
{
|
|
return _value;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return _value.ToString();
|
|
}
|
|
}
|
|
} |