From 5bd193e64f4461cb64f86cb65b5adcd94fe75fdd Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 6 Apr 2014 14:17:55 +0200 Subject: [PATCH] frontend: Let the parser support brackets in matcher expressions. --- src/frontend/grammar.y | 7 +++++++ t/frontend/parser_test.c | 4 ++++ 2 files changed, 11 insertions(+) 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 }, -- 2.30.2