Пример #1
0
 // Recursively call the lower arithmetic stage until a primitive
 private Func <AbstractExpressionNode> ArithmeticOperation(ArithmeticLevel level)
 {
     return(() =>
     {
         if (level == ArithmeticLevel.Primitive)
         {
             return ArithmeticPrimitive();
         }
         return ExecuteIfOperator
         (
             ArithmeticOperation(level - 1)(),
             ArithmeticOperation(level),
             GetOperators(level)
         );
     });
 }
Пример #2
0
        // Retrieve the operators that belong to the arithmetic level
        private IEnumerable <OperatorType> GetOperators(ArithmeticLevel level)
        {
            switch (level)
            {
            case ArithmeticLevel.Powerable:
                yield return(OperatorType.Pow);

                break;

            case ArithmeticLevel.Divisible:
                yield return(OperatorType.Div);

                yield return(OperatorType.EuclidianDiv);

                break;

            case ArithmeticLevel.Multiplicative:
                yield return(OperatorType.Mod);

                yield return(OperatorType.Mul);

                break;

            case ArithmeticLevel.Additive:
                yield return(OperatorType.Add);

                yield return(OperatorType.Sub);

                break;

            case ArithmeticLevel.BitwiseAnd:
                yield return(OperatorType.BitwiseAnd);

                break;

            case ArithmeticLevel.BitwiseOr:
                yield return(OperatorType.BitwiseOr);

                break;

            case ArithmeticLevel.Comparative:
                yield return(OperatorType.Equals);

                yield return(OperatorType.NotEquals);

                yield return(OperatorType.Greater);

                yield return(OperatorType.NotGreater);

                yield return(OperatorType.Less);

                yield return(OperatorType.NotLess);

                break;

            case ArithmeticLevel.LogicalAnd:
                yield return(OperatorType.AndAlso);

                break;

            case ArithmeticLevel.LogicalOr:
                yield return(OperatorType.OrElse);

                break;
            }
        }