Пример #1
0
        public static string[] tokenize(string expression)
        {
            String[] exps = new string[] {
                "\\$?(?:(?![0-9-])[\\w-]+:)?(?![0-9-])[\\w-]+",
                "\\d+\\.\\d+",
                "\\.\\d+",
                "\\d+",
                "\\/\\/",
                @"\/",
                "\\.\\.",
                "\\.",
                "\\s+",
                "::",
                ",",
                "@",
                "-",
                "=",
                "!=",
                "<=",
                "<",
                ">=",
                ">",
                "\\|",
                "\\+",
                "\\*",
                "\\(",
                "\\)",
                "\\[",
                "\\]",
                "\"[^\"]*\"",
                "'[^']*'"
            };

            string ex = string.Join("|", exps);

            List <String> pString = new List <string>();

            Match match = Regex.Match(expression, ex, RegexOptions.IgnoreCase);

            while (match.Success)
            {
                if (!XPathLexer.RegexTest(match.Value, @"^\s+$"))
                {
                    pString.Add(match.Value);
                }
                match = match.NextMatch();
            }

            if (pString.Count == 0)
            {
                throw new Exception("Invalid XPath expression");
            }


            return(pString.ToArray());
        }
Пример #2
0
 public XPathAnalyzer(string expression)
 {
     this.lexer = new XPathLexer(expression);
 }
Пример #3
0
 public XPathAnalyzer(string expression)
 {
     this.lexer = new XPathLexer(expression);
 }
Пример #4
0
 public XPathLexer(string expression)
 {
     this.tokens = XPathLexer.tokenize(expression);
     this.index  = 0;
 }