From: Sebastian Harl Date: Sun, 6 Apr 2014 12:17:55 +0000 (+0200) Subject: frontend: Let the parser support brackets in matcher expressions. X-Git-Tag: sysdb-0.1.0~137 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5bd193e64f4461cb64f86cb65b5adcd94fe75fdd;p=sysdb.git frontend: Let the parser support brackets in matcher expressions. --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index abc5165..4bade3b 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -90,6 +90,8 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %left AND %left CMP_EQUAL %left CMP_REGEX +%left '(' ')' +%left '.' %type statements %type statement @@ -266,6 +268,11 @@ expression: ; matcher: + '(' matcher ')' + { + $$ = $2; + } + | matcher AND matcher { $$ = sdb_store_con_matcher($1, $3); diff --git a/t/frontend/parser_test.c b/t/frontend/parser_test.c index 705e732..ffeca8f 100644 --- a/t/frontend/parser_test.c +++ b/t/frontend/parser_test.c @@ -153,6 +153,10 @@ START_TEST(test_parse_matcher) "service.name = 'name' OR " "attribute.name = 'name' AND " "attribute.foo = 'bar'", -1, MATCHER_OR }, + { "(host.name = 'name' OR " + "service.name = 'name') AND " + "(attribute.name = 'name' OR " + "attribute.foo = 'bar')", -1, MATCHER_AND }, /* syntax errors */ { "LIST", -1, -1 },