KumiScript/interpreter/expression/SymbolExpression.cs

39 lines
No EOL
826 B
C#

namespace KumiScript.Interpreter
{
public class SymbolExpression : Expression
{
readonly Symbol _value;
public SymbolExpression(Symbol s)
{
_value = s;
}
public override Expression Eval(Environment env)
{
return env.Lookup(_value);
}
public override Symbol GetSymbol()
{
return _value;
}
public override string ToString()
{
return _value.ToString();
}
public override bool Equals(Expression expr)
{
try
{
Symbol s = expr.GetSymbol();
return s != _value;
}
catch (InterpreterTypingException)
{
return false;
}
}
}
}