Ejemplo n.º 1
0
        private Node ParseSubExpr(int callerPrec)
        {
            XPathOperator op;
            Node          opnd;

            // Check for unary operators
            if (scanner.Kind == LexKind.Minus)
            {
                op = XPathOperator.UnaryMinus;
                int opPrec = XPathOperatorPrecedence[(int)op];
                scanner.NextLex();
                opnd = builder.Operator(op, ParseSubExpr(opPrec), default(Node));
            }
            else
            {
                opnd = ParseUnionExpr();
            }

            // Process binary operators
            while (true)
            {
                op = (scanner.Kind <= LexKind.LastOperator) ? (XPathOperator)scanner.Kind : XPathOperator.Unknown;
                int opPrec = XPathOperatorPrecedence[(int)op];
                if (opPrec <= callerPrec)
                {
                    return(opnd);
                }

                // Operator's precedence is greater than the one of our caller, so process it here
                scanner.NextLex();
                opnd = builder.Operator(op, opnd, ParseSubExpr(/*callerPrec:*/ opPrec));
            }
        }
Ejemplo n.º 2
0
        /**************************************************************************************************/
        /*  Expressions                                                                                   */
        /**************************************************************************************************/

        /*
         *   Expr   ::= OrExpr
         *   OrExpr ::= AndExpr ('or' AndExpr)*
         */
        private Node ParseExpr()
        {
            Node opnd = ParseAndExpr();

            while (scanner.IsKeyword("or"))
            {
                scanner.NextLex();
                opnd = builder.Operator(XPathOperator.Or, opnd, ParseAndExpr());
            }
            return(opnd);
        }
Ejemplo n.º 3
0
        private Node ParseSubExpr(int callerPrec)
        {
            if (++parseSubExprDepth > MaxParseSubExprDepth)
            {
                if (System.Xml.XmlConfiguration.XsltConfigSection.LimitXPathComplexity)
                {
                    throw scanner.CreateException(System.Xml.Utils.Res.Xslt_InputTooComplex);
                }
            }

            XPathOperator op;
            Node          opnd;

            // Check for unary operators
            if (scanner.Kind == LexKind.Minus)
            {
                op = XPathOperator.UnaryMinus;
                int opPrec = XPathOperatorPrecedence[(int)op];
                scanner.NextLex();
                opnd = builder.Operator(op, ParseSubExpr(opPrec), default(Node));
            }
            else
            {
                opnd = ParseUnionExpr();
            }

            // Process binary operators
            while (true)
            {
                op = (scanner.Kind <= LexKind.LastOperator) ? (XPathOperator)scanner.Kind : XPathOperator.Unknown;
                int opPrec = XPathOperatorPrecedence[(int)op];
                if (opPrec <= callerPrec)
                {
                    break;
                }

                // Operator's precedence is greater than the one of our caller, so process it here
                scanner.NextLex();
                opnd = builder.Operator(op, opnd, ParseSubExpr(/*callerPrec:*/ opPrec));
            }
            --parseSubExprDepth;
            return(opnd);
        }
Ejemplo n.º 4
0
        private Node ParseSubExpr(int callerPrec)
        {
            if (++_parseSubExprDepth > MaxParseSubExprDepth)
            {
                if (LocalAppContextSwitches.LimitXPathComplexity)
                {
                    throw _scanner.CreateException(SR.Xslt_InputTooComplex);
                }
            }

            XPathOperator op;
            Node          opnd;

            // Check for unary operators
            if (_scanner.Kind == LexKind.Minus)
            {
                op = XPathOperator.UnaryMinus;
                int opPrec = s_XPathOperatorPrecedence[(int)op];
                _scanner.NextLex();
                opnd = _builder.Operator(op, ParseSubExpr(opPrec), default(Node));
            }
            else
            {
                opnd = ParseUnionExpr();
            }

            // Process binary operators
            while (true)
            {
                op = (_scanner.Kind <= LexKind.LastOperator) ? (XPathOperator)_scanner.Kind : XPathOperator.Unknown;
                int opPrec = s_XPathOperatorPrecedence[(int)op];
                if (opPrec <= callerPrec)
                {
                    break;
                }

                // Operator's precedence is greater than the one of our caller, so process it here
                _scanner.NextLex();
                opnd = _builder.Operator(op, opnd, ParseSubExpr(/*callerPrec:*/ opPrec));
            }
            --_parseSubExprDepth;
            return(opnd);
        }