Tokenizes a standard search query in name: operations mapping.

    Example:
        moo:bla, foo:~<=1, foo:ll..ff

        {
          'moo': ['bla'],
          'foo': ['~<=1', 'll..ff']
        }
199697
def tokenize_query(query: str) -> Dict[str, Iterable]:
    
    expressions = split_query(query)
    name_operation_tuples = [parse_expression(expression) for expression in expressions]
    operation_by_name = defaultdict(list)
    for name, operation in name_operation_tuples:
        operation_by_name[name].append(operation)
    return operation_by_name
864293
def get_query_tokens(query):
    
    query = preprocess_query(query)
    parsed = sqlparse.parse(query)

    # handle empty queries (#12)
    if not parsed:
        return []

    tokens = TokenList(parsed[0].tokens).flatten()
    # print([(token.value, token.ttype) for token in tokens])

    return [token for token in tokens if token.ttype is not Whitespace]
992319
function (op, args) {
            var likeOps = ["~", "~*", "LIKE", "ILIKE"];
            var notLikeOps = ["!~", "!~*", "NOT LIKE", "NOT ILIKE"];
            var regExpOps = ["~", "!~", "~*", "!~*"];
            var binaryOps = ["~", "!~", "LIKE", "NOT LIKE"];
            if (likeOps.indexOf(op) !== -1 || notLikeOps.indexOf(op) !== -1) {
                return format("(%s%s %s%s %s)", this.literal(args[0]), notLikeOps.indexOf(op) !== -1 ? " NOT" : "",
                    regExpOps.indexOf(op) !== -1 ? "REGEXP" : "LIKE", binaryOps.indexOf(op) !== -1 ? " BINARY" : "",
                    this.literal(args[1]));
            } else if (op === "||") {
                if (args.length > 1) {
                    return format("CONCAT(%s)", args.map(this.literal, this).join(", "));
                } else {
                    return this.literal(args[0]);
                }
            } else if (op === "B~") {
                return format("CAST(~%s AS SIGNED INTEGER)", this.literal(args[0]));
            } else {
                return this._super(arguments);
            }
        }
1288041
def query_term(term)
      # rubocop:disable Style/GuardClause
      if term.is_a?(Symbol)
        return term.to_s
      elsif term.is_a?(Integer)
        return term
      elsif term.is_a?(TrueClass)
        return term
      elsif !term.is_a?(Term)
        return "'#{term}'"
      end
      # rubocop:enable Style/GuardClause
      terms = term.args.map { |t| query_term(t) }
      case term.operator.symbol
      when :_and
        { :$and => terms }
      when :_or
        { :$or => terms }
      when :_not
        # $not currently (<=2.5.1) only supports negating equality operators.
        # so you can do { field: { $not : { [$eq,$gt,$lt,...] } }
        # but there is no way to negate an entire expression.
        # see https://jira.mongodb.org/browse/SERVER-10708
        { :$nor => terms }
      when :_equal
        { term.args[0] => stringify(term.args[1]) }
      when :_not_equal
        { term.args[0] => { :$ne => stringify(term.args[1]) } }
      when :_match
        { term.args[0] => { :$regex => term.args[1].to_s } }
      when :_in
        { term.args[0] => { :$in => term.args[1] } }
      when :_greater
        { term.args[0] => { :$gt => term.args[1] } }
      when :_greater_or_equal
        { term.args[0] => { :$gte => term.args[1] } }
      when :_less
        { term.args[0] => { :$lt => term.args[1] } }
      when :_less_or_equal
        { term.args[0] => { :$lte => term.args[1] } }
      else
        raise "can't handle operator '#{term.operator}' yet"
      end
    end
1071568
def convert_to_match_query(ir_blocks):
    """"""
    output_block = ir_blocks[-1]
    if not isinstance(output_block, ConstructResult):
        raise AssertionError(u'Expected last IR block to be ConstructResult, found: '
                             u'{} {}'.format(output_block, ir_blocks))
    ir_except_output = ir_blocks[:-1]

    folds, ir_except_output_and_folds = extract_folds_from_ir_blocks(ir_except_output)

    # Extract WHERE Filter
    global_operation_ir_blocks_tuple = _extract_global_operations(ir_except_output_and_folds)
    global_operation_blocks, pruned_ir_blocks = global_operation_ir_blocks_tuple
    if len(global_operation_blocks) > 1:
        raise AssertionError(u'Received IR blocks with multiple global operation blocks. Only one '
                             u'is allowed: {} {}'.format(global_operation_blocks, ir_blocks))
    if len(global_operation_blocks) == 1:
        if not isinstance(global_operation_blocks[0], Filter):
            raise AssertionError(u'Received non-Filter global operation block. {}'
                                 .format(global_operation_blocks[0]))
        where_block = global_operation_blocks[0]
    else:
        where_block = None

    match_steps = _split_ir_into_match_steps(pruned_ir_blocks)

    match_traversals = _split_match_steps_into_match_traversals(match_steps)

    return MatchQuery(
        match_traversals=match_traversals,
        folds=folds,
        output_block=output_block,
        where_block=where_block,
    )
961750
function _tokenize( prop ) {

  var tokens = [],
      patterns,
      src = prop.source;

  src = typeof src !== 'string' ? src : src.split(' ');

  patterns = {
    operator: /^[+\-\*\/\%]$/, // +-*/%
    // @TODO Improve this regex to cover numbers like 1,000,000
    number: /^\$?\d+[\.,]?\d+$/
  };

  function _pushToken( val, type ) {
    var token = {
      value: val,
      type: type
    };
    tokens.push( token );
  }

  // Return early if it's a function.
  if ( typeof src === 'function' ) {
    _pushToken( src, 'function' );
    return tokens;
  }

  // @TODO DRY this up.
  for ( var i = 0, len = src.length; i < len; i++ ) {
    if ( patterns.operator.test(src[i]) ) {
      _pushToken( src[i].match(patterns.operator)[0], 'operator' );
    } else if ( patterns.number.test(src[i]) ) {
      _pushToken( parseFloat( src[i].match(patterns.number)[0] ), 'number' );
    } else {
      _pushToken( src[i], 'name' );
    }
  }
  return tokens;

}
407554
def complete_pool_name(arg):
    

    search_string = '^'
    if arg is not None:
        search_string += arg

    res = Pool.search({
        'operator': 'regex_match',
        'val1': 'name',
        'val2': search_string
    })

    ret = []
    for p in res['result']:
        ret.append(p.name)

    return ret
879342
def _search_regex(ops: dict, regex_pat: str):
    
    custom_regexps = list(filter(None, [dic['regex'] for op, dic in ops.items() if 'regex' in dic]))
    op_names = [op for op, dic in ops.items() if 'regex' not in dic]
    regex = [regex_pat.format(_ops_regex(op_names))] if len(op_names) > 0 else []
    return re.compile('|'.join(custom_regexps + regex))
305735
def tokenize(s):
    
    return [m.group(m.lastindex) for m in _tdl_re.finditer(s)]
663105
public static Map<String, Object> parseQuerystring(String query) {
        String[] params = query.split("&");
        Map<String, Object> map = new HashMap<String, Object>();
        for (String param : params) {
            String[] nameValue = param.split("=");
            map.put(nameValue[0], nameValue[1]);
        }
        return map;
    }
1184001
def underscore_search(input, list, first_match=false)
      meth = first_match ? :find : :select
      return (first_match ? input : [input]) if list.include?(input)
      input = input.to_s
      if input.include?("_")
        underscore_regex = input.split('_').map {|e|
          Regexp.escape(e) }.join("([^_]+)?_")
        list.send(meth) {|e| e.to_s =~ /^#{underscore_regex}/ }
      else
        escaped_input = Regexp.escape(input)
        list.send(meth) {|e| e.to_s =~ /^#{escaped_input}/ }
      end
    end
19255
function tokenizeEscape(match, value) {
    var index = tokenized.length;
    tokenized[index] = "'+\n_.escape(" + value + ") +\n'";
    return token + index;
  }
883089
def _canonicalize_query(self, query):

        

        def transform_query(q):

            for encoder in self.query_encoders:
                q = encoder.encode(q,[])

            if isinstance(q, dict):
                nq = {}
                for key,value in q.items():
                    new_key = key
                    if isinstance(value,dict) and len(value) == 1 and list(value.keys())[0].startswith('$'):
                        if list(value.keys())[0] in ('$all','$in'):
                            if list(value.values())[0] and isinstance(list(value.values())[0][0],Document):
                                if self._use_pk_based_refs:
                                    new_key+='.pk'
                                else:
                                    new_key+='.__ref__'
                    elif isinstance(value,Document):
                        if self._use_pk_based_refs:
                            new_key+='.pk'
                        else:
                            new_key+='.__ref__'
                    nq[new_key] = transform_query(value)
                return nq
            elif isinstance(q, (list,QuerySet,tuple)):
                return [transform_query(x) for x in q]
            elif isinstance(q,Document):
                collection = self.get_collection_for_obj(q)
                if self._use_pk_based_refs:
                    return q.pk
                else:
                    return "%s:%s" % (collection,q.pk)
            else:
                return q

        return transform_query(query)
908725
def tokenize_asdl(buf):
    """"""
    for lineno, line in enumerate(buf.splitlines(), 1):
        for m in re.finditer(r'\s*(\w+|--.*|.)', line.strip()):
            c = m.group(1)
            if c[0].isalpha():
                # Some kind of identifier
                if c[0].isupper():
                    yield Token(TokenKind.ConstructorId, c, lineno)
                else:
                    yield Token(TokenKind.TypeId, c, lineno)
            elif c[:2] == '--':
                # Comment
                break
            else:
                # Operators
                try:
                    op_kind = TokenKind.operator_table[c]
                except KeyError:
                    raise ASDLSyntaxError('Invalid operator %s' % c, lineno)
                yield Token(op_kind, c, lineno)
1022858
function (query) {
        var fieldList = ['name', 'owner', 'description', 'keyword'];
        var parsedField = _.find(fieldList, function (field) {
          return query.indexOf(field + ':') === 0;
        });
        var parsedQuery = parsedField ? query.replace(new RegExp('^' + parsedField + ':'), '') : query;
        return {query: parsedQuery, field: parsedField};
      }
787709
function toMongooseArgs(args) {
  // Covert name_first to name: {first}
  let keyDepth = [];
  return (0, _entries2.default)(args).reduce((args, _ref7) => {
    var _ref8 = (0, _slicedToArray3.default)(_ref7, 2);

    let key = _ref8[0];
    let value = _ref8[1];

    keyDepth = key.split('_');
    if (keyDepth.length === 1) return (0, _assign2.default)(args, { [key]: value });
    keyDepth.reduce((args, depth, index) => {
      if (index === keyDepth.length - 1) {
        args[depth] = value;
        return;
      }
      args[depth] = args[depth] || {};
      return args[depth];
    }, args);
    return args;
  }, {});
}
445322
function (query) {
	this.toXml = function () {
		return {
			"NPANXXSearchAndOrderType": {
				"NpaNxx": {_text: query.npaNxx},
				"EnableTNDetail": {_text: query.enableTnDetail || query.enableTNDetail},
				"EnableLCA": {_text: query.enableLca || query.enableLCA},
				"Quantity": {_text: query.quantity || 1}
			}
		};
	};
}