public Tokenizer AddToken(string token, bool caseSensitive, bool needsSeparators, params object[] tags) { ThrowIfImmutable(); tree.AddToken(token, caseSensitive, needsSeparators, tags); return(this); }
private static TokenTree Setup() { TokenTree tree = new TokenTree(); tree.AddToken("select", false, true, "select"); tree.AddToken("contains", false, true, new string[] { "value", "textsearch", "contains" }); tree.AddToken("freetext", false, true, new string[] { "value", "textsearch", "freetext" }); tree.AddToken("as", false, true, "as"); tree.AddToken("top", false, true, "top"); tree.AddToken("distinct", false, true, "distinct"); tree.AddToken("percent", false, true, "percent"); tree.AddToken("with ties", false, true, "with ties"); // do not localize tree.AddToken(",", false, false, "comma"); tree.AddToken("from", false, true, "from"); tree.AddToken("where", false, true, "where"); tree.AddToken("order by", false, true, "order by"); // do not localize tree.AddToken("min", false, true, new string[] { "function", "value", "min" }); tree.AddToken("max", false, true, new string[] { "function", "value", "max" }); tree.AddToken("avg", false, true, new string[] { "function", "value", "avg" }); tree.AddToken("sum", false, true, new string[] { "function", "value", "sum" }); tree.AddToken("soundex", false, true, new string[] { "function", "value", "soundex" }); tree.AddToken("count", false, true, new string[] { "function", "value", "count" }); tree.AddToken("isnull", false, true, new string[] { "function", "value", "isnull" }); tree.AddToken("in", false, true, new string[] { "compare", "in" }); tree.AddToken("like", false, true, new string[] { "compare", "like" }); tree.AddToken(">", false, false, new string[] { "compare", ">" }); tree.AddToken("<", false, false, new string[] { "compare", "<" }); tree.AddToken("<=", false, false, new string[] { "compare", "<=" }); tree.AddToken(">=", false, false, new string[] { "compare", ">=" }); tree.AddToken("=<", false, false, new string[] { "compare", "<=" }); tree.AddToken("=>", false, false, new string[] { "compare", ">=" }); tree.AddToken("!=", false, false, new string[] { "compare", "!=" }); tree.AddToken("<>", false, false, new string[] { "compare", "!=" }); tree.AddToken("=", false, false, new string[] { "compare", "=" }); tree.AddToken("is", false, true, new string[] { "compare", "=" }); tree.AddToken("(", false, false, new string[] { "(", "value" }); tree.AddToken(")", false, false, ")"); tree.AddToken("[", false, false, "["); tree.AddToken("]", false, false, "]"); tree.AddToken("+", false, false, new string[] { "math", "add", "sign" }); tree.AddToken("-", false, false, new string[] { "math", "minus", "sign" }); tree.AddToken("/", false, false, new string[] { "math", "div" }); tree.AddToken("^", false, false, new string[] { "math", "xor" }); tree.AddToken("%", false, false, new string[] { "math", "mod" }); tree.AddToken("*", false, false, new string[] { "identifier", "property path", "value", "math", "mul" }); // do not localize tree.AddToken("¤", false, true, new string[] { "identifier", "property path", "value" }); // do not localize tree.AddToken("and", false, true, new string[] { "boolop", "and" }); tree.AddToken("or", false, true, new string[] { "boolop", "or" }); tree.AddToken("&&", false, false, new string[] { "boolop", "and" }); tree.AddToken("||", false, false, new string[] { "boolop", "or" }); tree.AddToken("not", false, true, new string[] { "math", "not" }); tree.AddToken("!", false, false, new string[] { "math", "not" }); tree.AddToken("asc", false, true, "direction"); tree.AddToken("desc", false, true, "direction"); tree.AddToken("true", false, true, new string[] { "value", "boolean", "true" }); tree.AddToken("false", false, true, new string[] { "value", "boolean", "false" }); tree.AddToken("between", false, true, new string[] { "between" }); tree.AddToken("null", false, true, new string[] { "value", "null" }); tree.AddToken("?", false, false, new string[] { "value", "?", "parameter" }); tree.AddExpression(false, true, new RangePatternMatcher('\"', '\"', '\"'), new string[] { "value", "string", "string \"" }); // do not localize tree.AddExpression(false, true, new RangePatternMatcher('\'', '\'', '\''), new string[] { "value", "string", "string '" }); // do not localize tree.AddExpression(false, true, new RangePatternMatcher('#'), new string[] { "value", "date" }); tree.AddExpression(false, true, new RangePatternMatcher('{', '}'), new string[] { "value", "guid" }); tree.AddExpression(false, true, new DecPatternMatcher(), new string[] { "value", "decimal" }); // tree.AddExpression(false, true, new RegexPatternMatcher(@"(\@?[a-zA-Z]{1}(\w*)\.?)*"), new string[] {"property path","value"}); // do not localize //tree.AddExpression(false, true, new RegexPatternMatcher(@"(\@?[a-zA-Z]{1}(\w*))"),new string[] {"identifier","property path","value"}); // do not localize //tree.AddExpression(false, true, new RegexPatternMatcher(@"(\@?[a-zA-Z]{1}(\w*)\.{1})*(([a-zA-Z]{1}(\w*))|\*|\¤)"),new string[] {"identifier","property path","value"}); // do not localize tree.AddExpression(false, true, new PropertyPathPatterhMatcher(), new string[] { "identifier", "property path", "value" }); // do not localize return(tree); }