X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Ffrontend%2Fgrammar.y;h=34a9c6b6474502d9fc059df45a6ed93a79890567;hp=8e5ddf6e5eff7a1e32646ad0d62795109a2b61f9;hb=56b97a180a53aecbfe9f7162b8ece3faae973cf9;hpb=c08c6541795e2ca4da72640a449347d7b708b1dc diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 8e5ddf6..34a9c6b 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -69,6 +69,8 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); const char *sstr; /* static string */ char *str; + sdb_data_t data; + sdb_llist_t *list; sdb_conn_node_t *node; @@ -81,16 +83,20 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %token AND OR NOT WHERE %token CMP_EQUAL CMP_NEQUAL CMP_REGEX CMP_NREGEX +%token CMP_LT CMP_LE CMP_GE CMP_GT %token FETCH LIST LOOKUP %token IDENTIFIER STRING +%token INTEGER FLOAT + /* Precedence (lowest first): */ %left OR %left AND -%left NOT +%right NOT %left CMP_EQUAL CMP_NEQUAL +%left CMP_LT CMP_LE CMP_GE CMP_GT %left CMP_REGEX CMP_NREGEX %left '(' ')' %left '.' @@ -107,6 +113,8 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %type op +%type data + %destructor { free($$); } %destructor { sdb_object_deref(SDB_OBJ($$)); } @@ -290,12 +298,12 @@ matcher: * Parse matchers comparing object attributes with a value. */ compare_matcher: - IDENTIFIER '.' IDENTIFIER op STRING + IDENTIFIER '.' IDENTIFIER op data { - $$ = sdb_store_matcher_parse_cmp($1, $3, $4, $5); + $$ = sdb_store_matcher_parse_cmp($1, $3, $4, &$5); free($1); $1 = NULL; free($3); $3 = NULL; - free($5); $5 = NULL; + sdb_data_free_datum(&$5); } ; @@ -307,6 +315,22 @@ op: CMP_REGEX { $$ = "=~"; } | CMP_NREGEX { $$ = "!~"; } + | + CMP_LT { $$ = "<"; } + | + CMP_LE { $$ = "<="; } + | + CMP_GE { $$ = ">="; } + | + CMP_GT { $$ = ">"; } + ; + +data: + STRING { $$.type = SDB_TYPE_STRING; $$.data.string = $1; } + | + INTEGER { $$ = $1; } + | + FLOAT { $$ = $1; } ; %%