public decimal Eval(Dictionary <string, object> values) { switch (Value) { case "*": return(LeftChild.Eval(values) * RightChild.Eval(values)); case "+": return(LeftChild.Eval(values) + RightChild.Eval(values)); case "-": return(LeftChild.Eval(values) - RightChild.Eval(values)); case "/": return(LeftChild.Eval(values) / RightChild.Eval(values)); case "%": return(LeftChild.Eval(values) % RightChild.Eval(values)); } if (LeftChild == null && RightChild == null) { if (NodeType == TokenType.LITERAL) { return(decimal.Parse(Value)); } return(Convert.ToDecimal(values[Value])); } throw new InvalidOperationException(); }