Esempio n. 1
0
		public static AstNode ParseXPathPattern(string xpathPattern) {
			XPathScanner scanner = new XPathScanner(xpathPattern);
			XPathParser  parser  = new XPathParser(scanner);
            AstNode result = parser.ParsePattern(null);
            if (scanner.Kind != XPathScanner.LexKind.Eof) {
                throw new XPathException(Res.Xp_InvalidToken, scanner.SourceText);
            }
			return result;
		}
Esempio n. 2
0
 private static bool IsPrimaryExpr(XPathScanner scanner)
 {
     return(
         scanner.Kind == XPathScanner.LexKind.String ||
         scanner.Kind == XPathScanner.LexKind.Number ||
         scanner.Kind == XPathScanner.LexKind.Dollar ||
         scanner.Kind == XPathScanner.LexKind.LParens ||
         scanner.Kind == XPathScanner.LexKind.Name && scanner.CanBeFunction && !IsNodeType(scanner)
         );
 }
Esempio n. 3
0
 private static bool IsNodeType(XPathScanner scaner)
 {
     return(
         scaner.Prefix.Length == 0 && (
             scaner.Name == "node" ||
             scaner.Name == "text" ||
             scaner.Name == "processing-instruction" ||
             scaner.Name == "comment"
             )
         );
 }
Esempio n. 4
0
        private Axis.AxisType GetAxis(XPathScanner scaner)
        {
            Debug.Assert(scaner.Kind == XPathScanner.LexKind.Axe);
            object axis = AxesTable[scaner.Name];

            if (axis == null)
            {
                throw new XPathException(Res.Xp_InvalidToken, scanner.SourceText);
            }
            return((Axis.AxisType)axis);
        }
Esempio n. 5
0
        public static AstNode ParseXPathPattern(string xpathPattern)
        {
            XPathScanner scanner = new XPathScanner(xpathPattern);
            XPathParser  parser  = new XPathParser(scanner);
            AstNode      result  = parser.ParsePattern(null);

            if (scanner.Kind != XPathScanner.LexKind.Eof)
            {
                throw new XPathException(Res.Xp_InvalidToken, scanner.SourceText);
            }
            return(result);
        }
Esempio n. 6
0
 private XPathParser(XPathScanner scanner)
 {
     this.scanner = scanner;
 }
Esempio n. 7
0
 private Axis.AxisType GetAxis(XPathScanner scaner) {
     Debug.Assert(scaner.Kind == XPathScanner.LexKind.Axe);
     object axis = AxesTable[scaner.Name];
     if (axis == null) {
         throw new XPathException(Res.Xp_InvalidToken, scanner.SourceText);
     }
     return (Axis.AxisType) axis;
 }
Esempio n. 8
0
 void NextLex(XPathScanner.LexKind t) {
     Debug.Assert(this.scanner.Kind == t);
     NextLex();
 }
Esempio n. 9
0
 void PassToken(XPathScanner.LexKind t) {
     CheckToken(t);
     NextLex();
 }
Esempio n. 10
0
        // --------------- Helper methods ----------------------

        void CheckToken(XPathScanner.LexKind t) {
            if (this.scanner.Kind != t) {
                throw new XPathException(Res.Xp_InvalidToken, this.scanner.SourceText);
            }
        }
Esempio n. 11
0
		private static bool IsPrimaryExpr(XPathScanner scanner) {
			return (
				scanner.Kind == XPathScanner.LexKind.String  ||
				scanner.Kind == XPathScanner.LexKind.Number  ||
				scanner.Kind == XPathScanner.LexKind.Dollar  ||
				scanner.Kind == XPathScanner.LexKind.LParens ||
				scanner.Kind == XPathScanner.LexKind.Name && scanner.CanBeFunction && ! IsNodeType(scanner)
			);
		}
Esempio n. 12
0
		private static bool IsStep(XPathScanner.LexKind lexKind) {
			return (
				lexKind == XPathScanner.LexKind.Dot    ||
				lexKind == XPathScanner.LexKind.DotDot ||
				lexKind == XPathScanner.LexKind.At     ||
				lexKind == XPathScanner.LexKind.Axe    ||
				lexKind == XPathScanner.LexKind.Star   ||
				lexKind == XPathScanner.LexKind.Name          // NodeTest is also Name
			);
		}
Esempio n. 13
0
		private XPathParser(XPathScanner scanner) {
            this.scanner = scanner;
		}
Esempio n. 14
0
 private static bool IsNodeType(XPathScanner scaner) {
     return (
         scaner.Prefix.Length == 0 && (
             scaner.Name == "node"                   || 
             scaner.Name == "text"                   || 
             scaner.Name == "processing-instruction" || 
             scaner.Name == "comment"
         )
     );
 }
Esempio n. 15
0
 private XPathParser(XPathScanner scanner) => _Scanner = scanner;