diff --git a/gertty/search/__init__.py b/gertty/search/__init__.py index 7902970..2dbfc1a 100644 --- a/gertty/search/__init__.py +++ b/gertty/search/__init__.py @@ -62,9 +62,18 @@ class SearchCompiler(object): if __name__ == '__main__': class Dummy(object): pass + query = 'status:open AND topic:enable_swift' + lexer = tokenizer.SearchTokenizer() + lexer.input(query) + while True: + token = lexer.token() + if not token: + break + print token + app = Dummy() app.config = Dummy() app.config.username = 'bob' search = SearchCompiler(app) - x = search.parse('owner:self') + x = search.parse(query) print x diff --git a/gertty/search/parser.py b/gertty/search/parser.py index b0ccfc0..0840305 100644 --- a/gertty/search/parser.py +++ b/gertty/search/parser.py @@ -47,12 +47,12 @@ def SearchParser(): def p_boolean_expr(p): '''boolean_expr : expression AND expression | expression OR expression''' - if p[2] == 'and': + if p[2].lower() == 'and': p[0] = and_(p[1], p[3]) - elif p[2] == 'or': + elif p[2].lower() == 'or': p[0] = or_(p[1], p[3]) else: - raise SyntaxError() + raise gertty.search.SearchSyntaxError("Boolean %s not recognized" % p[2]) def p_negative_expr(p): '''negative_expr : NOT expression