X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fparser%2Fgrammar.y;h=6654780c185ddcd88ad3d3d8517fc48c1e566813;hb=f3b0a31699113fd9f4bf505929bd22a924153c50;hp=bdba4ea4e453022c19e8a8eaa5f7b80852fa53d4;hpb=c8d51914ef24f01f935d2853d57f05d0b0a0af9e;p=sysdb.git diff --git a/src/parser/grammar.y b/src/parser/grammar.y index bdba4ea..6654780 100644 --- a/src/parser/grammar.y +++ b/src/parser/grammar.y @@ -104,7 +104,7 @@ sdb_parser_yyerrorf(YYLTYPE *lval, sdb_parser_yyscan_t scanner, const char *fmt, sdb_llist_t *list; sdb_ast_node_t *node; - struct { char *type; char *id; } metric_store; + struct { char *type; char *id; sdb_time_t last_update; } metric_store; } %start statements @@ -127,6 +127,8 @@ sdb_parser_yyerrorf(YYLTYPE *lval, sdb_parser_yyscan_t scanner, const char *fmt, /* NULL token */ %token NULL_T +%token TRUE FALSE + %token FETCH LIST LOOKUP STORE TIMESERIES %token IDENTIFIER STRING @@ -279,13 +281,13 @@ statement: fetch_statement: FETCH object_type STRING filter_clause { - $$ = sdb_ast_fetch_create($2, $3, NULL, $4); + $$ = sdb_ast_fetch_create($2, NULL, -1, NULL, $3, 1, $4); CK_OOM($$); } | FETCH object_type STRING '.' STRING filter_clause { - $$ = sdb_ast_fetch_create($2, $3, $5, $6); + $$ = sdb_ast_fetch_create($2, $3, -1, NULL, $5, 1, $6); CK_OOM($$); } ; @@ -337,42 +339,42 @@ store_statement: STORE HOST_T STRING last_update_clause { $$ = sdb_ast_store_create(SDB_HOST, NULL, 0, NULL, - $3, $4, NULL, NULL, SDB_DATA_NULL); + $3, $4, NULL, NULL, 0, SDB_DATA_NULL); CK_OOM($$); } | STORE SERVICE_T STRING '.' STRING last_update_clause { $$ = sdb_ast_store_create(SDB_SERVICE, $3, 0, NULL, - $5, $6, NULL, NULL, SDB_DATA_NULL); + $5, $6, NULL, NULL, 0, SDB_DATA_NULL); CK_OOM($$); } | STORE METRIC_T STRING '.' STRING metric_store_clause last_update_clause { $$ = sdb_ast_store_create(SDB_METRIC, $3, 0, NULL, - $5, $7, $6.type, $6.id, SDB_DATA_NULL); + $5, $7, $6.type, $6.id, $6.last_update, SDB_DATA_NULL); CK_OOM($$); } | STORE HOST_T ATTRIBUTE_T STRING '.' STRING data last_update_clause { $$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, 0, NULL, - $6, $8, NULL, NULL, $7); + $6, $8, NULL, NULL, 0, $7); CK_OOM($$); } | STORE SERVICE_T ATTRIBUTE_T STRING '.' STRING '.' STRING data last_update_clause { $$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, SDB_SERVICE, $6, - $8, $10, NULL, NULL, $9); + $8, $10, NULL, NULL, 0, $9); CK_OOM($$); } | STORE METRIC_T ATTRIBUTE_T STRING '.' STRING '.' STRING data last_update_clause { $$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, SDB_METRIC, $6, - $8, $10, NULL, NULL, $9); + $8, $10, NULL, NULL, 0, $9); CK_OOM($$); } ; @@ -383,9 +385,11 @@ last_update_clause: /* empty */ { $$ = sdb_gettime(); } metric_store_clause: - STORE STRING STRING { $$.type = $2; $$.id = $3; } + STORE STRING STRING datetime { $$.type = $2; $$.id = $3; $$.last_update = $4; } + | + STORE STRING STRING { $$.type = $2; $$.id = $3; $$.last_update = 0; } | - /* empty */ { $$.type = $$.id = NULL; } + /* empty */ { $$.type = $$.id = NULL; $$.last_update = 0; } /* * TIMESERIES . [START ] [END ]; @@ -453,13 +457,17 @@ comparison: | ANY expression cmp expression { - $$ = sdb_ast_iter_create(SDB_AST_ANY, $3, $2, $4); + sdb_ast_node_t *n = sdb_ast_op_create($3, NULL, $4); + CK_OOM(n); + $$ = sdb_ast_iter_create(SDB_AST_ANY, $2, n); CK_OOM($$); } | ALL expression cmp expression { - $$ = sdb_ast_iter_create(SDB_AST_ALL, $3, $2, $4); + sdb_ast_node_t *n = sdb_ast_op_create($3, NULL, $4); + CK_OOM(n); + $$ = sdb_ast_iter_create(SDB_AST_ALL, $2, n); CK_OOM($$); } | @@ -477,6 +485,34 @@ comparison: CK_OOM($$); } | + expression IS TRUE + { + $$ = sdb_ast_op_create(SDB_AST_ISTRUE, NULL, $1); + CK_OOM($$); + } + | + expression IS NOT TRUE + { + $$ = sdb_ast_op_create(SDB_AST_ISTRUE, NULL, $1); + CK_OOM($$); + $$ = sdb_ast_op_create(SDB_AST_NOT, NULL, $$); + CK_OOM($$); + } + | + expression IS FALSE + { + $$ = sdb_ast_op_create(SDB_AST_ISFALSE, NULL, $1); + CK_OOM($$); + } + | + expression IS NOT FALSE + { + $$ = sdb_ast_op_create(SDB_AST_ISFALSE, NULL, $1); + CK_OOM($$); + $$ = sdb_ast_op_create(SDB_AST_NOT, NULL, $$); + CK_OOM($$); + } + | expression IN expression { $$ = sdb_ast_op_create(SDB_AST_IN, $1, $3); @@ -600,6 +636,8 @@ field: BACKEND_T { $$ = SDB_FIELD_BACKEND; } | VALUE_T { $$ = SDB_FIELD_VALUE; } + | + TIMESERIES { $$ = SDB_FIELD_TIMESERIES; } ; cmp: