Пример #1
0
        internal void SetPreviousPattern(Pattern prev, bool isAncestor)
        {
            LocationPathPattern toSet = LastPathPattern;

            toSet.patternPrevious = (LocationPathPattern)prev;
            toSet.isAncestor      = isAncestor;
        }
        internal void SetPreviousPattern(Pattern prev, bool isAncestor)
        {
            LocationPathPattern lastPathPattern = this.LastPathPattern;

            lastPathPattern.patternPrevious = (LocationPathPattern)prev;
            lastPathPattern.isAncestor      = isAncestor;
        }
Пример #3
0
 internal static Pattern Compile(Expression e)
 {
     if (e is ExprUNION)
     {
         return(new UnionPattern(Pattern.Compile(((ExprUNION)e).left), Pattern.Compile(((ExprUNION)e).right)));
     }
     if (e is ExprRoot)
     {
         return(new LocationPathPattern(new NodeTypeTest(Axes.Self, XPathNodeType.Root)));
     }
     if (e is NodeTest)
     {
         return(new LocationPathPattern((NodeTest)e));
     }
     if (e is ExprFilter)
     {
         return(new LocationPathPattern((ExprFilter)e));
     }
     if (e is ExprSLASH)
     {
         Pattern             prev = Pattern.Compile(((ExprSLASH)e).left);
         LocationPathPattern locationPathPattern = (LocationPathPattern)Pattern.Compile(((ExprSLASH)e).right);
         locationPathPattern.SetPreviousPattern(prev, false);
         return(locationPathPattern);
     }
     if (e is ExprSLASH2)
     {
         if (((ExprSLASH2)e).left is ExprRoot)
         {
             return(Pattern.Compile(((ExprSLASH2)e).right));
         }
         Pattern             prev2 = Pattern.Compile(((ExprSLASH2)e).left);
         LocationPathPattern locationPathPattern2 = (LocationPathPattern)Pattern.Compile(((ExprSLASH2)e).right);
         locationPathPattern2.SetPreviousPattern(prev2, true);
         return(locationPathPattern2);
     }
     else
     {
         if (e is XPathFunctionId)
         {
             ExprLiteral exprLiteral = ((XPathFunctionId)e).Id as ExprLiteral;
             return(new IdPattern(exprLiteral.Value));
         }
         if (e is XsltKey)
         {
             return(new KeyPattern((XsltKey)e));
         }
         return(null);
     }
 }
Пример #4
0
        internal static Pattern Compile(Expression e)
        {
            if (e is ExprUNION)
            {
                return(new UnionPattern(
                           Compile(((ExprUNION)e).left),
                           Compile(((ExprUNION)e).right)
                           ));
            }

            if (e is ExprRoot)
            {
                return(new LocationPathPattern(
                           new NodeTypeTest(Axes.Self, XPathNodeType.Root)
                           ));
            }

            if (e is NodeTest)
            {
                return(new LocationPathPattern(
                           (NodeTest)e
                           ));
            }

            if (e is ExprFilter)
            {
                return(new LocationPathPattern(
                           (ExprFilter)e
                           ));
            }

            if (e is ExprSLASH)
            {
                Pattern             p0 = Compile(((ExprSLASH)e).left);
                LocationPathPattern p1
                    = (LocationPathPattern)Compile(((ExprSLASH)e).right);

                p1.SetPreviousPattern(p0, false);
                return(p1);
            }

            if (e is ExprSLASH2)
            {
                if (((ExprSLASH2)e).left is ExprRoot)
                {
                    return(Compile(((ExprSLASH2)e).right));
                }

                Pattern             p0 = Compile(((ExprSLASH2)e).left);
                LocationPathPattern p1
                    = (LocationPathPattern)Compile(((ExprSLASH2)e).right);

                p1.SetPreviousPattern(p0, true);
                return(p1);
            }

            if (e is XPathFunctionId)
            {
                ExprLiteral id = ((XPathFunctionId)e).Id as ExprLiteral;
                return(new IdPattern(id.Value));
            }

            if (e is XsltKey)
            {
                return(new KeyPattern((XsltKey)e));
            }

            return(null);            // throw Exception outer this method.
        }