public static string Calculate(string expression) { Token token = new Kooboo.Dynamic.Calculator.Parser.Token(expression); Evaluator evaluator = new Evaluator(token); string value; string errorMsg; if (!evaluator.Evaluate(out value, out errorMsg)) { throw new CalculateExpression(errorMsg); } return value; }
public static string Calculate(string expression) { Token token = new Kooboo.Dynamic.Calculator.Parser.Token(expression); Evaluator evaluator = new Evaluator(token); string value; string errorMsg; if (!evaluator.Evaluate(out value, out errorMsg)) { throw new CalculateExpression(errorMsg); } return(value); }
/// <summary> /// This method is called when we add a token to Group.Tokens.DeleteOnSubmit(tk). This methods allows us to collect the /// unique variables. /// </summary> /// <param name="tk"></param> internal void UpdateVariables(Token tk) { // loop through the variables in the current token foreach (Parser.Variable var in tk.Variables) { // check if the variable exists it the Group.Variables collection if (this.variables.VariableExists(var.VariableName) == false) { // we found a new variable to add to our Group.Variables collection this.variables.Add(var.VariableName); } } }