Did I find the right examples for you? yes no

All Samples(12)  |  Call(6)  |  Derive(0)  |  Import(6)

        def parse_query(expr_str):
    def parse_terminal(pstate):
        next_tag = pstate.next_tag()
        if next_tag is _tag:
            return make_tag_query(pstate.next_str_and_advance())
        elif next_tag is _negtag:
            return NotQuery(make_tag_query(pstate.next_str_and_advance()[1:]))
        elif next_tag is _fulltext:
            return FulltextQuery(pstate.next_str_and_advance()[1:-1])
        elif next_tag is _dated:
            pstate.advance()
            return DatedQuery()
        elif next_tag in _STATELESS_TERMINALS:
            pstate.advance()
            return _STATELESS_TERMINALS[next_tag]
        elif next_tag in [_id]:
            result = IdQuery(int(pstate.next_match_obj().group(1)))
            pstate.advance()
            return result
        elif next_tag in [_before, _after]:
            from parsedatetime.parsedatetime import Calendar
            cal = Calendar()
            timetup = cal.parse(pstate.next_match_obj().group(1))
            pstate.advance()
            import time
            return DateQuery(next_tag==_before, time.mktime(timetup[0]))
        else:
            pstate.expected("terminal")

    def inner_parse(pstate, min_precedence=0):
        pstate.expect_not_end()

        if pstate.is_next(_not):
            pstate.advance()
            left_query = make_not_query(inner_parse(pstate, _PREC_NOT))
        elif pstate.is_next(_openpar):
            pstate.advance()
            left_query = inner_parse(pstate)
            pstate.expect(_closepar)
            pstate.advance()
        else:
            left_query = parse_terminal(pstate)

        did_something = True
        while did_something:
            did_something = False
            if pstate.is_at_end():
                return left_query

            next_tag = pstate.next_tag()

            if next_tag is _and and _PREC_AND > min_precedence:
                pstate.advance()
                left_query = make_and_query([left_query, inner_parse(pstate, _PREC_AND)])
                did_something = True
            elif next_tag is _or and _PREC_OR > min_precedence:
                pstate.advance()
                left_query = make_or_query([left_query, inner_parse(pstate, _PREC_OR)])
                did_something = True
            elif next_tag in _TERMINALS + [_not, _openpar] and _PREC_AND > min_precedence:
                left_query = make_and_query([left_query, inner_parse(pstate, _PREC_AND)])
                did_something = True

        return left_query


    from synoptic.lex import LexIterator, lex
    pstate = LexIterator(
        [(tag, s, idx, matchobj)
         for (tag, s, idx, matchobj) in lex(_LEX_TABLE, expr_str)
         if tag is not _whitespace], expr_str)

    if pstate.is_at_end():
        return TagQuery(u"home")

    result = inner_parse(pstate)
    if not pstate.is_at_end():
        pstate.raise_parse_error("leftover input after completed parse")

    return result
        


src/s/y/synoptic-2013.1/synoptic/__init__.py   synoptic(Download)
    def get_itemversions_for_request(self, request):
        from synoptic.query import parse_query
        parsed_query = parse_query(request.GET.get("query", ""))
 
        if "max_timestamp" in request.GET:
 
        if query != "":
            from synoptic.query import parse_query
            parsed_query = parse_query(query)
 
    def http_get_items(self, request):
        qry = request.GET.get("query", "")
 
        from synoptic.query import parse_query
        parsed_query = parse_query(qry)