Exemplo n.º 1
0
        private static bool CheckPriority(NumericExpressionOperator topOfStack, NumericExpressionOperator newOperator)
        {
            int stackPriority       = GetPriority(topOfStack);
            int newOperatorPriority = GetPriority(newOperator);

            return(newOperatorPriority < stackPriority);
        }
Exemplo n.º 2
0
        private static int GetPriority(NumericExpressionOperator neo)
        {
            switch (neo.GetOperatorType())
            {
            case NumericExpressionOperatorType.Modulo:
                return(2);

            case NumericExpressionOperatorType.Multiply:
                return(2);

            case NumericExpressionOperatorType.Divide:
                return(2);

            case NumericExpressionOperatorType.Plus:
                return(1);

            case NumericExpressionOperatorType.Minus:
                return(1);
            }
            return(0);
        }