X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ffrontend%2Fgrammar.y;h=ef479efc336ba30e90182ae72557c0892091fc07;hb=d8dafe689b17088740721432558b00d12482c583;hp=129b4613009c9d5fc12aa71d2a470c0b02feed31;hpb=6330f15bb3b4be4826a50ab6ec2d70e248198f03;p=sysdb.git diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 129b461..ef479ef 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -113,6 +113,7 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %nonassoc IS %left '+' '-' %left '*' '/' '%' +%left '[' ']' %left '(' ')' %left '.' @@ -131,7 +132,7 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %type expression -%type op +%type cmp %type data interval interval_elem @@ -234,6 +235,7 @@ fetch_statement: $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL, conn_fetch_t, conn_fetch_destroy)); + CONN_FETCH($$)->type = SDB_HOST; CONN_FETCH($$)->name = $3; CONN_FETCH($$)->filter = CONN_MATCHER($4); $$->cmd = CONNECTION_FETCH; @@ -291,6 +293,7 @@ lookup_statement: $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL, conn_lookup_t, conn_lookup_destroy)); + CONN_LOOKUP($$)->type = SDB_HOST; CONN_LOOKUP($$)->matcher = CONN_MATCHER($3); CONN_LOOKUP($$)->filter = CONN_MATCHER($4); $$->cmd = CONNECTION_LOOKUP; @@ -352,7 +355,7 @@ condition: $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL, conn_matcher_t, conn_matcher_destroy)); - $$->cmd = CONNECTION_EXPR; + $$->cmd = CONNECTION_MATCHER; CONN_MATCHER($$)->matcher = $1; } ; @@ -390,41 +393,41 @@ matcher: ; /* - * . + * . * * Parse matchers comparing object attributes with a value. */ compare_matcher: - ':' IDENTIFIER op expression + '.' IDENTIFIER cmp expression { $$ = sdb_store_matcher_parse_field_cmp($2, $3, $4); free($2); $2 = NULL; sdb_object_deref(SDB_OBJ($4)); } | - IDENTIFIER op expression + IDENTIFIER cmp expression { $$ = sdb_store_matcher_parse_cmp($1, NULL, $2, $3); free($1); $1 = NULL; sdb_object_deref(SDB_OBJ($3)); } | - IDENTIFIER '.' IDENTIFIER op expression + IDENTIFIER '[' IDENTIFIER ']' cmp expression { - $$ = sdb_store_matcher_parse_cmp($1, $3, $4, $5); + $$ = sdb_store_matcher_parse_cmp($1, $3, $5, $6); free($1); $1 = NULL; free($3); $3 = NULL; - sdb_object_deref(SDB_OBJ($5)); + sdb_object_deref(SDB_OBJ($6)); } | - IDENTIFIER '.' IDENTIFIER IS NULL_T + IDENTIFIER '[' IDENTIFIER ']' IS NULL_T { $$ = sdb_store_matcher_parse_cmp($1, $3, "IS", NULL); free($1); $1 = NULL; free($3); $3 = NULL; } | - IDENTIFIER '.' IDENTIFIER IS NOT NULL_T + IDENTIFIER '[' IDENTIFIER ']' IS NOT NULL_T { sdb_store_matcher_t *m; m = sdb_store_matcher_parse_cmp($1, $3, "IS", NULL); @@ -478,13 +481,27 @@ expression: sdb_object_deref(SDB_OBJ($3)); $3 = NULL; } | - ':' IDENTIFIER + expression CONCAT expression + { + $$ = sdb_store_expr_create(SDB_DATA_CONCAT, $1, $3); + sdb_object_deref(SDB_OBJ($1)); $1 = NULL; + sdb_object_deref(SDB_OBJ($3)); $3 = NULL; + } + | + '.' IDENTIFIER { int field = sdb_store_parse_field_name($2); free($2); $2 = NULL; $$ = sdb_store_expr_fieldvalue(field); } | + IDENTIFIER '[' IDENTIFIER ']' + { + $$ = sdb_store_expr_attrvalue($3); + free($1); $1 = NULL; + free($3); $3 = NULL; + } + | data { $$ = sdb_store_expr_constvalue(&$1); @@ -492,7 +509,7 @@ expression: } ; -op: +cmp: CMP_EQUAL { $$ = "="; } | CMP_NEQUAL { $$ = "!="; }