/// <summary> /// check that all operand types are expected: int or double only. /// TODO: string? for concatenation? later. /// /// </summary> /// <param name="execResult"></param> /// <param name="listExpr"></param> /// <returns></returns> private bool CheckTypeOperandExprCalculation(ExecResult execResult, List <ExpressionExecBase> listExprExecBase) { bool ret = true; foreach (ExpressionExecBase exprExecBase in listExprExecBase) { // is it an int? ExprExecValueInt exprInt = exprExecBase as ExprExecValueInt; if (exprInt != null) { // yes! continue; } // is it a double? ExprExecValueDouble exprDouble = exprExecBase as ExprExecValueDouble; if (exprDouble == null) { // neither an int or a double , error! execResult.AddErrorExec(ErrorCode.ExprCalculationOperandTypeUnExcepted, "Content", exprExecBase.Expr.Token.Value, "Position", exprExecBase.Expr.Token.Position.ToString()); ret = false; } } return(ret); }
/// <summary> /// Execute a functionCall. /// First execute parameters and then execute the function code attached/linked. /// </summary> /// <param name="exprExecResult"></param> /// <param name="exprFunctionCall"></param> /// <param name="exprExecBase"></param> /// <returns></returns> private bool ExecExpressionFunctionCall(ExecResult exprExecResult, ExprFunctionCall exprFunctionCall, out ExpressionExecBase exprExecBase) { ExpressionExecBase exprExecParamBase; List <ExpressionExecBase> listExprExecParam = new List <ExpressionExecBase>(); bool res = true; exprExecBase = null; // get the function code FunctionToCallMapper functionToCallMapper = _exprEvalConfig.ListFunctionToCallMapper.Find(f => f.FunctionCallName.Equals(exprFunctionCall.FunctionName, StringComparison.InvariantCultureIgnoreCase)); if (functionToCallMapper == null) { // error exprExecResult.AddErrorExec(ErrorCode.FunctionCallNotLinked, "FunctionCallName", exprFunctionCall.FunctionName); return(false); } // execute params of the function foreach (ExpressionBase exprParam in exprFunctionCall.ListExprParameters) { res &= ExecExpression(exprExecResult, exprParam, out exprExecParamBase); listExprExecParam.Add(exprExecParamBase); } // a param execution failed if (!res) { return(false); } // execute the function code attached to the functionCall, provide executed params return(_exprExecutorFunctionCall.ExecExpressionFunctionCall(exprExecResult, exprFunctionCall, functionToCallMapper, listExprExecParam, out exprExecBase)); }
/// <summary> /// Execute the calculation expression. /// exp: a+b /// /// Only int or double type are authorized. /// /// todo: +tard: pour les strings si opérateur +/Plus, faire une concaténation! /// </summary> /// <param name="exprExecResult"></param> /// <param name="exprLogicalNot"></param> /// <param name="exprExecBase"></param> /// <returns></returns> private bool ExecExpressionCalculation(ExecResult execResult, ExprCalculation exprCalculation, out ExpressionExecBase exprExecBase) { // the final result of the execution exprExecBase = null; // check the number of operands if (exprCalculation.ListExprOperand.Count > Definitions.ExprCalculationMaxOperandsCount) { execResult.AddErrorExec(ErrorCode.ExprCalculationTooManyOperands, "Content", exprExecBase.Expr.Token.Value, "Position", exprExecBase.Expr.Token.Position.ToString()); return(false); } // first execute all operands, one by one List <ExpressionExecBase> listExprExecBase; if (!ExecListExpression(execResult, exprCalculation.ListExprOperand, out listExprExecBase)) { // an error occurs return(false); } // check that all operand types are expected: int or double only if (!CheckTypeOperandExprCalculation(execResult, listExprExecBase)) { // an error occurs return(false); } // execute the calculation ExprExecutorCalculation exprExecutorCalculation = new ExprExecutorCalculation(); return(exprExecutorCalculation.Process(execResult, exprCalculation, listExprExecBase, out exprExecBase)); }
public bool GetCheckParamDouble(ExecResult exprExecResult, string functionCallName, ExpressionExecBase param, out ExprExecValueDouble exprParamDouble) { exprParamDouble = param as ExprExecValueDouble; if (exprParamDouble == null) { exprExecResult.AddErrorExec(ErrorCode.FunctionCallParamTypeWrong, "FunctionCallName", functionCallName, "ParamTypeExpected", "double"); //, "ParamType", param.GetType().ToString()); return(false); } return(true); }
/// <summary> /// error occurs on executing the function. /// /// </summary> /// <param name="exprExecResult"></param> /// <param name="e"></param> /// <returns></returns> public bool AddErrorExecFailed(ExecResult exprExecResult, Exception e) { string innerException = ""; if (e.InnerException != null) { innerException = e.InnerException.ToString(); } exprExecResult.AddErrorExec(ErrorCode.FunctionCallExecException, "Message", e.Message, "InnerException", innerException); return(false); }
/// <summary> /// Exec the function call, return a string value. /// can have any, one or more parameters. /// </summary> /// <param name="exprExecResult"></param> /// <param name="functionToCallMapper"></param> /// <param name="exprExecFunctionCallBool"></param> /// <param name="listExprExecParam"></param> /// <param name="exprExecBase"></param> /// <returns></returns> public bool Exec(ExecResult exprExecResult, ExprExecFunctionCallString exprExecFunctionCallString, List <ExpressionExecBase> listExprExecParam, out ExpressionExecBase exprExecBase) { exprExecBase = null; string res; bool caseManaged; if (!ExecFuncRetString_Params(exprExecResult, exprExecFunctionCallString, listExprExecParam, out caseManaged, out res)) { // an error occurs return(false); } if (!caseManaged) { exprExecResult.AddErrorExec(ErrorCode.ExpressionTypeNotYetImplemented, "Type", "FunctionCall"); return(false); } // execute the function linked to the functionCall found in the expression exprExecFunctionCallString.Value = res; exprExecBase = exprExecFunctionCallString; return(true); }
/// <summary> /// Do the calculation: res := operandLeft operator operandRight. /// Both operand must be number, int or double. /// the operator can be: +, -, *, /. /// </summary> /// <param name="execResult"></param> /// <param name="exprExecBase"></param> /// <returns></returns> private bool DoCalculationTwoOperands(ExecResult execResult, ExprCalculation exprCalculation, ExpressionExecBase exprExecBaseLeft, ExpressionExecBase exprExecBaseRight, ExprOperatorCalculation operatorCalc, out ExpressionExecBase exprExecCalcResult) { exprExecCalcResult = null; CalcIntOrDouble calcIntOrDoubleLeft = CalcIntOrDouble.NotDefined; CalcIntOrDouble calcIntOrDoubleRight = CalcIntOrDouble.NotDefined; int valLeftInt = 0; int valRightInt = 0; double valLeftDouble = 0; double valRightDouble = 0; //---parse the left operand ExprExecValueInt exprExecValueLeftInt = exprExecBaseLeft as ExprExecValueInt; if (exprExecValueLeftInt != null) { valLeftInt = exprExecValueLeftInt.Value; calcIntOrDoubleLeft = CalcIntOrDouble.IsInt; } else { ExprExecValueDouble exprExecValueLeftDouble = exprExecBaseLeft as ExprExecValueDouble; if (exprExecValueLeftDouble != null) { valLeftDouble = exprExecValueLeftDouble.Value; calcIntOrDoubleLeft = CalcIntOrDouble.IsDouble; } } //---parse the right operand ExprExecValueInt exprExecValueRightInt = exprExecBaseRight as ExprExecValueInt; if (exprExecValueRightInt != null) { valRightInt = exprExecValueRightInt.Value; calcIntOrDoubleRight = CalcIntOrDouble.IsInt; } else { ExprExecValueDouble exprExecValueRightDouble = exprExecBaseRight as ExprExecValueDouble; if (exprExecValueRightDouble != null) { valRightDouble = exprExecValueRightDouble.Value; calcIntOrDoubleRight = CalcIntOrDouble.IsDouble; } } //----wrong type if (calcIntOrDoubleLeft == CalcIntOrDouble.NotDefined) { // other operators are not allowed on the boolean type (only bool) execResult.AddErrorExec(ErrorCode.ExprCalculationOperandTypeUnExcepted, "Position", exprExecBaseLeft.Expr.Token.Position.ToString(), "Operand", exprExecBaseLeft.Expr.Token.Value); return(false); } if (calcIntOrDoubleRight == CalcIntOrDouble.NotDefined) { // other operators are not allowed on the boolean type (only bool) execResult.AddErrorExec(ErrorCode.ExprCalculationOperandTypeUnExcepted, "Position", exprExecBaseRight.Expr.Token.Position.ToString(), "Operand", exprExecBaseRight.Expr.Token.Value); return(false); } // if one of both operand is an double, convert the other to a double if (calcIntOrDoubleLeft == CalcIntOrDouble.IsDouble || calcIntOrDoubleRight == CalcIntOrDouble.IsDouble) { if (calcIntOrDoubleLeft == CalcIntOrDouble.IsInt) { valLeftDouble = (double)valLeftInt; } if (calcIntOrDoubleRight == CalcIntOrDouble.IsInt) { valRightDouble = (double)valRightInt; } // used to define the calculation type calcIntOrDoubleLeft = CalcIntOrDouble.IsDouble; } //----calculate, depending on the operator: Plus if (operatorCalc.Operator == OperatorCalculationCode.Plus) { if (calcIntOrDoubleLeft == CalcIntOrDouble.IsDouble) { ExprExecValueDouble resDouble = new ExprExecValueDouble(); resDouble.Value = valLeftDouble + valRightDouble; exprExecCalcResult = resDouble; return(true); } ExprExecValueInt resInt = new ExprExecValueInt(); resInt.Value = valLeftInt + valRightInt; exprExecCalcResult = resInt; return(true); } //----calculate, depending on the operator: Minus if (operatorCalc.Operator == OperatorCalculationCode.Minus) { if (calcIntOrDoubleLeft == CalcIntOrDouble.IsDouble) { ExprExecValueDouble resDouble = new ExprExecValueDouble(); resDouble.Value = valLeftDouble - valRightDouble; exprExecCalcResult = resDouble; return(true); } ExprExecValueInt resInt = new ExprExecValueInt(); resInt.Value = valLeftInt - valRightInt; exprExecCalcResult = resInt; return(true); } //----calculate, depending on the operator: Multiplication if (operatorCalc.Operator == OperatorCalculationCode.Multiplication) { if (calcIntOrDoubleLeft == CalcIntOrDouble.IsDouble) { ExprExecValueDouble resDouble = new ExprExecValueDouble(); resDouble.Value = valLeftDouble * valRightDouble; exprExecCalcResult = resDouble; return(true); } ExprExecValueInt resInt = new ExprExecValueInt(); resInt.Value = valLeftInt * valRightInt; exprExecCalcResult = resInt; return(true); } //----calculate, depending on the operator: Division if (operatorCalc.Operator == OperatorCalculationCode.Division) { if (calcIntOrDoubleLeft == CalcIntOrDouble.IsDouble) { ExprExecValueDouble resDouble = new ExprExecValueDouble(); resDouble.Value = valLeftDouble / valRightDouble; exprExecCalcResult = resDouble; return(true); } // the result can be a double! double res = (double)valLeftInt / (double)valRightInt; double res2 = res - Math.Truncate(res); if (res2 == 0) { ExprExecValueInt resInt = new ExprExecValueInt(); resInt.Value = valLeftInt / valRightInt; exprExecCalcResult = resInt; return(true); } else { ExprExecValueDouble resDouble = new ExprExecValueDouble(); resDouble.Value = res; // valLeftInt / valRightInt; exprExecCalcResult = resDouble; return(true); } return(true); } // operator not yet implemented execResult.AddErrorExec(ErrorCode.ExprCalculationOperatorNotYetImplemented, "Position", exprExecBaseLeft.Expr.Token.Position.ToString(), "Operand", exprExecBaseLeft.Expr.Token.Value); return(false); }
/// <summary> /// Execute the logical expression. /// exp: (a AND b) /// /// Only bool type are authorized. /// </summary> /// <param name="exprExecResult"></param> /// <param name="exprComparison"></param> /// <param name="exprExecBase"></param> /// <returns></returns> private bool ExecExpressionLogical(ExecResult exprExecResult, ExprLogical exprLogical, out ExpressionExecBase exprExecBase) { exprExecBase = null; //----first step is to execute both operands ExpressionExecBase exprExecBaseLeft; ExecExpression(exprExecResult, exprLogical.ExprLeft, out exprExecBaseLeft); ExpressionExecBase exprExecBaseRight; ExecExpression(exprExecResult, exprLogical.ExprRight, out exprExecBaseRight); //---Are the operands boolean type? ExprExecValueBool exprExecValueLeftBool = exprExecBaseLeft as ExprExecValueBool; if (exprExecValueLeftBool != null) { // decode the right operand, should be a bool value too ExprExecValueBool exprExecValueRightBool = exprExecBaseRight as ExprExecValueBool; if (exprExecValueRightBool == null) { // the type of both operands mismatch! exprExecResult.AddErrorExec(ErrorCode.ExprLogicalOperandsTypeMismatchBoolExpected, "Position", exprLogical.ExprRight.Token.Position.ToString()); return(false); } ExprExecValueBool exprValueBoolResult = new ExprExecValueBool(); // is the operator AND? if (exprLogical.Operator == OperatorLogicalCode.And) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftBool.Value && exprExecValueRightBool.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator OR? if (exprLogical.Operator == OperatorLogicalCode.Or) { // ok, execute the comparison exprValueBoolResult.Value = (exprExecValueLeftBool.Value || exprExecValueRightBool.Value); exprExecBase = exprValueBoolResult; return(true); } // is the operator XOR? if (exprLogical.Operator == OperatorLogicalCode.Xor) { // ok, execute the comparison, the operator doesn't exists so do firts a OR exprValueBoolResult.Value = (exprExecValueLeftBool.Value || exprExecValueRightBool.Value); // the xor case: both operands are true so the result is false if (exprExecValueLeftBool.Value && exprExecValueRightBool.Value) { exprValueBoolResult.Value = false; } exprExecBase = exprValueBoolResult; return(true); } // other operators are not allowed on the boolean type (only bool) exprExecResult.AddErrorExec(ErrorCode.ExprLogicalOperatorNotAllowed, "Position", exprLogical.ExprLeft.Token.Position.ToString(), "Operator", exprLogical.Operator.ToString()); return(false); } //---Are the operands others type? -> error exprExecResult.AddErrorExec(ErrorCode.ExprLogicalOperandTypeNotAllowed, "Position", exprLogical.ExprLeft.Token.Position.ToString(), "Token", exprExecBaseLeft.GetType().ToString()); return(false); }
/// <summary> /// execute the expression, execute the right part, execute the left part, then exec the expr (as 2 value operands) /// /// Returns always a bool value. /// exp: a=12, a>=13 /// /// managed type; int and double. /// for the bool and the string type, only equals and diff are authorized. /// </summary> /// <param name="exprComparison"></param> /// <returns></returns> private bool ExecExpressionComparison(ExecResult exprExecResult, ExprComparison exprComparison, out ExpressionExecBase exprExecBase) { exprExecBase = null; //----first step is to decode/compile both operands ExpressionExecBase exprExecBaseLeft; ExecExpression(exprExecResult, exprComparison.ExprLeft, out exprExecBaseLeft); ExpressionExecBase exprExecBaseRight; ExecExpression(exprExecResult, exprComparison.ExprRight, out exprExecBaseRight); //---Are the operands boolean? ExprExecValueBool exprExecValueLeftBool = exprExecBaseLeft as ExprExecValueBool; if (exprExecValueLeftBool != null) { // decode the right operand, should be a bool value too ExprExecValueBool exprExecValueRightBool = exprExecBaseRight as ExprExecValueBool; if (exprExecValueRightBool == null) { // the type of both operands mismatch! exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperandsTypeMismatchBoolExpected, "Position", exprComparison.ExprRight.Token.Position.ToString()); return(false); } ExprExecValueBool exprValueBoolResult = new ExprExecValueBool(); // is the operator Equals? if (exprComparison.Operator == OperatorComparisonCode.Equals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftBool.Value == exprExecValueRightBool.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator different? if (exprComparison.Operator == OperatorComparisonCode.Different) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftBool.Value != exprExecValueRightBool.Value; exprExecBase = exprValueBoolResult; return(true); } // other operators are not allowed on the boolean type exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperatorNotAllowedForBoolType, "Position", exprComparison.ExprLeft.Token.Position.ToString(), "Operator", exprComparison.Operator.ToString()); return(false); } //---Are the operands integer? ExprExecValueInt exprExecValueLeftInt = exprExecBaseLeft as ExprExecValueInt; if (exprExecValueLeftInt != null) { // decode the right operand, should be an int value too ExprExecValueInt exprExecValueRightInt = exprExecBaseRight as ExprExecValueInt; if (exprExecValueRightInt == null) { // the type of both operands mismatch! exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperandsTypeMismatchIntExpected, "Position", exprComparison.ExprRight.Token.Position.ToString()); return(false); } ExprExecValueBool exprValueBoolResult = new ExprExecValueBool(); // is the operator Equals? if (exprComparison.Operator == OperatorComparisonCode.Equals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftInt.Value == exprExecValueRightInt.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator different? if (exprComparison.Operator == OperatorComparisonCode.Different) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftInt.Value != exprExecValueRightInt.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator greater than? if (exprComparison.Operator == OperatorComparisonCode.Greater) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftInt.Value > exprExecValueRightInt.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator lesser than? if (exprComparison.Operator == OperatorComparisonCode.Less) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftInt.Value < exprExecValueRightInt.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator greater or equals than? if (exprComparison.Operator == OperatorComparisonCode.GreaterEquals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftInt.Value >= exprExecValueRightInt.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator lesser or equals than? if (exprComparison.Operator == OperatorComparisonCode.LessEquals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftInt.Value <= exprExecValueRightInt.Value; exprExecBase = exprValueBoolResult; return(true); } // other operators are not allowed on the boolean type (impossible to be there!) exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperatorNotYetImplementedForIntType, "Position", exprComparison.ExprLeft.Token.Position.ToString(), "Operator", exprComparison.Operator.ToString()); return(false); } //---Are the operands double? ExprExecValueDouble exprExecValueLeftDouble = exprExecBaseLeft as ExprExecValueDouble; if (exprExecValueLeftDouble != null) { // decode the right operand, should be an int value too ExprExecValueDouble exprExecValueRightDouble = exprExecBaseRight as ExprExecValueDouble; if (exprExecValueRightDouble == null) { // the type of both operands mismatch! exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperandsTypeMismatchDoubleExpected, "Position", exprComparison.ExprRight.Token.Position.ToString()); return(false); } // the result is always a bool (its a comparison) ExprExecValueBool exprValueBoolResult = new ExprExecValueBool(); // is the operator Equals? if (exprComparison.Operator == OperatorComparisonCode.Equals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftDouble.Value == exprExecValueRightDouble.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator different? if (exprComparison.Operator == OperatorComparisonCode.Different) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftDouble.Value != exprExecValueRightDouble.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator greater than? if (exprComparison.Operator == OperatorComparisonCode.Greater) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftDouble.Value > exprExecValueRightDouble.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator lesser than? if (exprComparison.Operator == OperatorComparisonCode.Less) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftDouble.Value < exprExecValueRightDouble.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator greater or equals than? if (exprComparison.Operator == OperatorComparisonCode.GreaterEquals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftDouble.Value >= exprExecValueRightDouble.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator lesser or equals than? if (exprComparison.Operator == OperatorComparisonCode.LessEquals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftDouble.Value <= exprExecValueRightDouble.Value; exprExecBase = exprValueBoolResult; return(true); } // other operators are not allowed on the boolean type (impossible to be there!) exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperatorNotYetImplementedForDoubleType, "Position", exprComparison.ExprLeft.Token.Position.ToString(), "Operator", exprComparison.Operator.ToString()); return(false); } //---Are the operands string? ExprExecValueString exprExecValueLeftString = exprExecBaseLeft as ExprExecValueString; if (exprExecValueLeftString != null) { // decode the right operand, should be a bool value too ExprExecValueString exprExecValueRightString = exprExecBaseRight as ExprExecValueString; if (exprExecValueRightString == null) { // the type of both operands mismatch! exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperandsTypeMismatchStringExpected, "Position", exprComparison.ExprRight.Token.Position.ToString()); return(false); } ExprExecValueBool exprValueBoolResult = new ExprExecValueBool(); // is the operator Equals? if (exprComparison.Operator == OperatorComparisonCode.Equals) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftString.Value == exprExecValueRightString.Value; exprExecBase = exprValueBoolResult; return(true); } // is the operator different? if (exprComparison.Operator == OperatorComparisonCode.Different) { // ok, execute the comparison exprValueBoolResult.Value = exprExecValueLeftString.Value != exprExecValueRightString.Value; exprExecBase = exprValueBoolResult; return(true); } // other operators are not allowed on the boolean type exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperatorNotAllowedForStringType, "Position", exprComparison.ExprLeft.Token.Position.ToString(), "Operator", exprComparison.Operator.ToString()); return(false); } // if reached, the operand type is not yet implemented (or unknowed) exprExecResult.AddErrorExec(ErrorCode.ExprComparisonOperandTypeNotYetImplemented, "Position", exprComparison.ExprLeft.Token.Position.ToString(), "Token", exprExecBaseLeft.Expr.Token.ToString()); return(false); }
/// <summary> /// start the execution, analyze and return the list of variables to create. /// todo: recréer un syntax tree, avec des valeurs! /// /// -->Doit renvoyer comme résultat un objet de type ExprValueXXX, non?? (si pas d'erreur). /// </summary> /// <returns></returns> private bool ExecExpression(ExecResult exprExecResult, ExpressionBase expr, out ExpressionExecBase exprExecBase) { exprExecBase = null; //----is it a final operand (value, var or call function)? ExprFinalOperand finalOperand = expr as ExprFinalOperand; if (finalOperand != null) { return(ExecExpressionFinalOperand(exprExecResult, finalOperand, out exprExecBase)); } //----is it a comparison expression? ExprComparison exprComparison = expr as ExprComparison; if (exprComparison != null) { // execute the expression, execute the right part, execute the left part, then exec the expr (as 2 value operands) return(ExecExpressionComparison(exprExecResult, exprComparison, out exprExecBase)); } //----is it a logical expression (bin/2 operands)? ExprLogical exprLogical = expr as ExprLogical; if (exprLogical != null) { return(ExecExpressionLogical(exprExecResult, exprLogical, out exprExecBase)); } //----is it a NOT logical expression? ExprLogicalNot exprLogicalNot = expr as ExprLogicalNot; if (exprLogicalNot != null) { return(ExecExpressionLogicalNot(exprExecResult, exprLogicalNot, out exprExecBase)); } //----is it a calculation expression? ExprCalculation exprCalculation = expr as ExprCalculation; if (exprCalculation != null) { // execute the expression, execute the right part, execute the left part, then exec the expr (as 2 value operands) return(ExecExpressionCalculation(exprExecResult, exprCalculation, out exprExecBase)); } //----is it function call? ExprFunctionCall exprFunctionCall = expr as ExprFunctionCall; if (exprFunctionCall != null) { return(ExecExpressionFunctionCall(exprExecResult, exprFunctionCall, out exprExecBase)); } //----is it a setValue expression? // todo: future // todo: error, expression not yet implemented!! exprExecResult.AddErrorExec(ErrorCode.ExpressionTypeNotYetImplemented, "Expr", expr.GetType().ToString()); return(false); }