Code

frontend: Let the parser support brackets in matcher expressions.
authorSebastian Harl <sh@tokkee.org>
Sun, 6 Apr 2014 12:17:55 +0000 (14:17 +0200)
committerSebastian Harl <sh@tokkee.org>
Sun, 6 Apr 2014 12:17:55 +0000 (14:17 +0200)
src/frontend/grammar.y
t/frontend/parser_test.c

index abc51656934edcffc8c6f32ddf7320f985541d77..4bade3b47af690eae54b703eb12d8b1fd477464c 100644 (file)
@@ -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 <list> statements
 %type <node> statement
@@ -266,6 +268,11 @@ expression:
        ;
 
 matcher:
+       '(' matcher ')'
+               {
+                       $$ = $2;
+               }
+       |
        matcher AND matcher
                {
                        $$ = sdb_store_con_matcher($1, $3);
index 705e7322370ee370fb0d3c2434f85a5668d44cb4..ffeca8f68b091d50e5c90c5d165edf2867986b1f 100644 (file)
@@ -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 },