Exemple #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());
        }
 public XPathAnalyzer(string expression)
 {
     this.lexer = new XPathLexer(expression);
 }
 public XPathAnalyzer(string expression)
 {
     this.lexer = new XPathLexer(expression);
 }
Exemple #4
0
 public XPathLexer(string expression)
 {
     this.tokens = XPathLexer.tokenize(expression);
     this.index  = 0;
 }