/// <summary> /// recursively evaluate the value of an ExpNode /// </summary> /// <param name="variables">a dictionary of variable names and values</param> /// <returns>the double value of the evaluated ExpNode</returns> internal double Evaluate(Dictionary <string, double> variables) { double value = 0.0d; var tokenHandler = TokenHandlerFactory.GenerateTokenHandler(Token); tokenHandler.HandleTreeEvaluation(this, variables, ref value); return(value); }
/// <summary> /// initialize variables, convert infix expression /// to postfix, then generate expression tree /// </summary> /// <param name="expression">a string containing an infix expression to convert to an expression tree</param> public ExpTree(string expression) { Variables = new Dictionary <string, double>(); _postfixTokens = new List <string>(); _tokenHandlers = TokenHandlerFactory.GenerateTokenHandlerList(); _encounteredError = false; If2Pf(expression); GenerateTree(); }