private AstNode ParseStepPattern(AstNode qyInput)
        {
            Axis.AxisType child = Axis.AxisType.Child;
            switch (this.scanner.Kind)
            {
            case XPathScanner.LexKind.At:
                child = Axis.AxisType.Attribute;
                this.NextLex();
                break;

            case XPathScanner.LexKind.Axe:
                child = this.GetAxis(this.scanner);
                if ((child != Axis.AxisType.Child) && (child != Axis.AxisType.Attribute))
                {
                    throw XPathException.Create("Xp_InvalidToken", this.scanner.SourceText);
                }
                this.NextLex();
                break;
            }
            XPathNodeType nodeType = (child == Axis.AxisType.Attribute) ? XPathNodeType.Attribute : XPathNodeType.Element;
            AstNode       input    = this.ParseNodeTest(qyInput, child, nodeType);

            while (XPathScanner.LexKind.LBracket == this.scanner.Kind)
            {
                input = new MS.Internal.Xml.XPath.Filter(input, this.ParsePredicate(input));
            }
            return(input);
        }
        private AstNode ParseStep(AstNode qyInput)
        {
            if (XPathScanner.LexKind.Dot == this.scanner.Kind)
            {
                this.NextLex();
                return(new Axis(Axis.AxisType.Self, qyInput));
            }
            if (XPathScanner.LexKind.DotDot == this.scanner.Kind)
            {
                this.NextLex();
                return(new Axis(Axis.AxisType.Parent, qyInput));
            }
            Axis.AxisType child = Axis.AxisType.Child;
            switch (this.scanner.Kind)
            {
            case XPathScanner.LexKind.At:
                child = Axis.AxisType.Attribute;
                this.NextLex();
                break;

            case XPathScanner.LexKind.Axe:
                child = this.GetAxis(this.scanner);
                this.NextLex();
                break;
            }
            XPathNodeType nodeType = (child == Axis.AxisType.Attribute) ? XPathNodeType.Attribute : XPathNodeType.Element;
            AstNode       input    = this.ParseNodeTest(qyInput, child, nodeType);

            while (XPathScanner.LexKind.LBracket == this.scanner.Kind)
            {
                input = new MS.Internal.Xml.XPath.Filter(input, this.ParsePredicate(input));
            }
            return(input);
        }
        private AstNode ParseFilterExpr(AstNode qyInput)
        {
            AstNode input = this.ParsePrimaryExpr(qyInput);

            while (this.scanner.Kind == XPathScanner.LexKind.LBracket)
            {
                input = new MS.Internal.Xml.XPath.Filter(input, this.ParsePredicate(input));
            }
            return(input);
        }
Пример #4
0
        private Query ProcessFilter(MS.Internal.Xml.XPath.Filter root, Flags flags, out Props props)
        {
            Props props2;
            bool  flag = (flags & Flags.Filter) == Flags.None;
            Query q    = this.ProcessNode(root.Condition, Flags.None, out props2);

            if (this.CanBeNumber(q) || ((props2 & (Props.HasLast | Props.HasPosition)) != Props.None))
            {
                props2 |= Props.HasPosition;
                flags  |= Flags.PosFilter;
            }
            flags &= ~Flags.SmartDesc;
            Query input = this.ProcessNode(root.Input, flags | Flags.Filter, out props);

            if (root.Input.Type != AstNode.AstType.Filter)
            {
                props &= ~Props.PosFilter;
            }
            if ((props2 & Props.HasPosition) != Props.None)
            {
                props |= Props.PosFilter;
            }
            FilterQuery query3 = input as FilterQuery;

            if (((query3 != null) && ((props2 & Props.HasPosition) == Props.None)) && (query3.Condition.StaticType != XPathResultType.Any))
            {
                Query condition = query3.Condition;
                if (condition.StaticType == XPathResultType.Number)
                {
                    condition = new LogicalExpr(Operator.Op.EQ, new NodeFunctions(Function.FunctionType.FuncPosition, null), condition);
                }
                q     = new BooleanExpr(Operator.Op.AND, condition, q);
                input = query3.qyInput;
            }
            if (((props & Props.PosFilter) != Props.None) && (input is DocumentOrderQuery))
            {
                input = ((DocumentOrderQuery)input).input;
            }
            if (this.firstInput == null)
            {
                this.firstInput = input as BaseAxisQuery;
            }
            bool flag2 = (input.Properties & QueryProps.Merge) != QueryProps.None;
            bool flag3 = (input.Properties & QueryProps.Reverse) != QueryProps.None;

            if ((props2 & Props.HasPosition) != Props.None)
            {
                if (flag3)
                {
                    input = new ReversePositionQuery(input);
                }
                else if ((props2 & Props.HasLast) != Props.None)
                {
                    input = new ForwardPositionQuery(input);
                }
            }
            if (flag && (this.firstInput != null))
            {
                if (flag2 && ((props & Props.PosFilter) != Props.None))
                {
                    input = new FilterQuery(input, q, false);
                    Query qyInput = this.firstInput.qyInput;
                    if (!(qyInput is ContextQuery))
                    {
                        this.firstInput.qyInput = new ContextQuery();
                        this.firstInput         = null;
                        return(new MergeFilterQuery(qyInput, input));
                    }
                    this.firstInput = null;
                    return(input);
                }
                this.firstInput = null;
            }
            return(new FilterQuery(input, q, (props2 & Props.HasPosition) == Props.None));
        }
        private AstNode ParseStepPattern(AstNode qyInput)
        {
            Axis.AxisType child = Axis.AxisType.Child;
            switch (this.scanner.Kind)
            {
                case XPathScanner.LexKind.At:
                    child = Axis.AxisType.Attribute;
                    this.NextLex();
                    break;

                case XPathScanner.LexKind.Axe:
                    child = this.GetAxis(this.scanner);
                    if ((child != Axis.AxisType.Child) && (child != Axis.AxisType.Attribute))
                    {
                        throw XPathException.Create("Xp_InvalidToken", this.scanner.SourceText);
                    }
                    this.NextLex();
                    break;
            }
            XPathNodeType nodeType = (child == Axis.AxisType.Attribute) ? XPathNodeType.Attribute : XPathNodeType.Element;
            AstNode input = this.ParseNodeTest(qyInput, child, nodeType);
            while (XPathScanner.LexKind.LBracket == this.scanner.Kind)
            {
                input = new MS.Internal.Xml.XPath.Filter(input, this.ParsePredicate(input));
            }
            return input;
        }
        private AstNode ParseStep(AstNode qyInput)
        {
            if (XPathScanner.LexKind.Dot == this.scanner.Kind)
            {
                this.NextLex();
                return new Axis(Axis.AxisType.Self, qyInput);
            }
            if (XPathScanner.LexKind.DotDot == this.scanner.Kind)
            {
                this.NextLex();
                return new Axis(Axis.AxisType.Parent, qyInput);
            }
            Axis.AxisType child = Axis.AxisType.Child;
            switch (this.scanner.Kind)
            {
                case XPathScanner.LexKind.At:
                    child = Axis.AxisType.Attribute;
                    this.NextLex();
                    break;

                case XPathScanner.LexKind.Axe:
                    child = this.GetAxis(this.scanner);
                    this.NextLex();
                    break;
            }
            XPathNodeType nodeType = (child == Axis.AxisType.Attribute) ? XPathNodeType.Attribute : XPathNodeType.Element;
            AstNode input = this.ParseNodeTest(qyInput, child, nodeType);
            while (XPathScanner.LexKind.LBracket == this.scanner.Kind)
            {
                input = new MS.Internal.Xml.XPath.Filter(input, this.ParsePredicate(input));
            }
            return input;
        }
 private AstNode ParseFilterExpr(AstNode qyInput)
 {
     AstNode input = this.ParsePrimaryExpr(qyInput);
     while (this.scanner.Kind == XPathScanner.LexKind.LBracket)
     {
         input = new MS.Internal.Xml.XPath.Filter(input, this.ParsePredicate(input));
     }
     return input;
 }