public TokenItem Evaluate(out string ErrorMsg) { // initialize the outgoing variables ErrorMsg = ""; // local variables string result = ""; // get the parent token object Token token = this.Parent.Parent.Parent; // create the evaluator object to evaluate the condition Evaluation.Engine.Evaluate.Evaluator eval = null; try { eval = new Evaluation.Engine.Evaluate.Evaluator(token); } catch (Exception err) { ErrorMsg = "Failed to evaluation the condition in IIFShortCircuit(): " + err.Message; XapLogger.Instance.Error(ErrorMsg); return(null); } // evaluate the condition if (eval.Evaluate(this.rpn_condition, out result, out ErrorMsg) == false) { return(null); } // determine if we need to run the "true" or "false" result Support.ExQueue <TokenItem> resultQueue = null; if (result.Trim().ToLower() == "true") { // evaluate the true parameter resultQueue = this.rpn_true; } else { // evaluate the false parameter resultQueue = this.rpn_false; } // do the final evaluation if (eval.Evaluate(resultQueue, out result, out ErrorMsg) == false) { return(null); } // all done return(new TokenItem(result, TokenType.Token_Operand, TokenDataType.Token_DataType_String, false)); }
public bool EvaluateGroup() { string value = ""; string ErrorMsg = ""; bool anyFailures = false; // first, populate the variable values in each of the tokens foreach (Parser.Token tk in this.tokens) { // loop through each tokens variables foreach (Parser.Variable var in tk.Variables) { if (this.variables.VariableExists(var.VariableName) == true) { var.VariableValue = this.variables[var.VariableName].VariableValue; } } // see if we have tokens and an RPN queue if ((tk.TokenItems.Count > 0) && (tk.RPNQueue.Count > 0)) { tk.LastErrorMessage = ""; // reset the last error message } // the variables for the token have been populated; evaluate the token Evaluate.Evaluator eval = new Evaluation.Engine.Evaluate.Evaluator(tk); if (eval.Evaluate(out value, out ErrorMsg) == false) { tk.LastErrorMessage = ErrorMsg; anyFailures = true; } } return(anyFailures); }