public IOperator RegisterOperator( string text, int precedence, DoubleOperandFunctionMatrix matrix, ShortCircuitMode shortCircuit = ShortCircuitMode.None, OperatorType operatorType = OperatorType.Operator) { var op = new Operator(operatorType, precedence, shortCircuit, (operandStack, vSet, parserPosition) => { var result = OperatorActions.DoOperation(matrix, operandStack, vSet); if (result != null) { throw new ExpressionEvaluatorException( parserPosition, ExpressionEvaluatorException.ExceptionCause.BadOperand, "Operator '" + text + "' cannot be applied to operands of type " + result.Item1 + " and " + result.Item2); } }, text ); Operators.Add(text, op); OperatorMatrices.Add(op, matrix); return(op); }
public Operator(OperatorType operatorType, int precedence, ShortCircuitMode shortCircuit, Action <Stack <IOperand>, IBackingStore, long> doOperation, string asString) { Precedence = precedence; ShortCircuit = shortCircuit; DoOperation = doOperation; AsString = asString; Type = operatorType; }