public IOperator RegisterUnaryCastOperator(OperandType operandType, int precedence, DoubleOperandFunctionMatrix matrix)
        {
            var text = operandType.ToString();

            var castToOperand = new Operand(operandType);

            var op = new Operator(
                OperatorType.UnaryCastOperator,
                precedence,
                ShortCircuitMode.None,
                (operandStack, vSet, parserPosition) =>
            {
                var result = OperatorActions.DoUnaryCastOperation(matrix, operandStack, vSet, castToOperand);
                if (result != null)
                {
                    throw new ExpressionEvaluatorException(parserPosition,
                                                           ExpressionEvaluatorException.ExceptionCause.BadUnaryOperand,
                                                           "Cast to (" + text + ") cannot be applied to operand of type " + result.Item1);
                }
            },
                text
                );

            Operators.Add(text, op);
            OperatorMatrices.Add(op, matrix);
            return(op);
        }
        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 IOperator RegisterSetEqualsOperator(string text, int precedence, DoubleOperandFunctionMatrix matrix)
        {
            var op = new Operator(OperatorType.Operator, precedence, ShortCircuitMode.None,

                                  (operandStack, vSet, parserPosition) =>
            {
                var result = OperatorActions.DoSetEquals(matrix, operandStack, vSet, parserPosition);
                // DoSetEquals throws its own exception.
            }


                                  , text);

            Operators.Add(text, op);
            OperatorMatrices.Add(op, matrix);
            return(op);
        }