From: Sebastian Harl Date: Tue, 21 Oct 2014 05:45:31 +0000 (+0200) Subject: frontend/grammar: Added support for the IN operator. X-Git-Tag: sysdb-0.6.0~87 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8b66b80ff28c28ee36ce43c96db94721557785fc;p=sysdb.git frontend/grammar: Added support for the IN operator. This is a matcher checking if a value is included in an array. It's mostly meant to be used to match backends at the moment. --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 78b45d2..23ba07f 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -92,7 +92,7 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %token AND OR IS NOT MATCHING FILTER %token CMP_EQUAL CMP_NEQUAL CMP_REGEX CMP_NREGEX -%token CMP_LT CMP_LE CMP_GE CMP_GT +%token CMP_LT CMP_LE CMP_GE CMP_GT IN %token CONCAT %token START END @@ -115,6 +115,7 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %left CMP_EQUAL CMP_NEQUAL %left CMP_LT CMP_LE CMP_GE CMP_GT %nonassoc CMP_REGEX CMP_NREGEX +%nonassoc IN %left CONCAT %nonassoc IS %left '+' '-' @@ -469,6 +470,13 @@ compare_matcher: $$ = sdb_store_isnnull_matcher($1); sdb_object_deref(SDB_OBJ($1)); } + | + expression IN expression + { + $$ = sdb_store_in_matcher($1, $3); + sdb_object_deref(SDB_OBJ($1)); + sdb_object_deref(SDB_OBJ($3)); + } ; expression: diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l index 9d8e73d..33b762c 100644 --- a/src/frontend/scanner.l +++ b/src/frontend/scanner.l @@ -55,6 +55,7 @@ static struct { { "END", END }, { "FETCH", FETCH }, { "FILTER", FILTER }, + { "IN", IN }, { "IS", IS }, { "LIST", LIST }, { "LOOKUP", LOOKUP },