summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cadb192)
raw | patch | inline | side by side (parent: cadb192)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 16 Jun 2014 06:35:19 +0000 (08:35 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 16 Jun 2014 06:35:19 +0000 (08:35 +0200) |
src/frontend/grammar.y | patch | blob | history |
diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index abab594b53a58ee0ddf440ceced7d2a5357b6883..75885c5259960433675b38f47a0bd90b857acff9 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
%name-prefix "sdb_fe_yy"
%union {
+ const char *sstr; /* static string */
char *str;
sdb_llist_t *list;
%type <m> matcher
compare_matcher
+%type <sstr> op
+
%destructor { free($$); } <str>
%destructor { sdb_object_deref(SDB_OBJ($$)); } <node> <m>
* Parse matchers comparing object attributes with a value.
*/
compare_matcher:
- IDENTIFIER '.' IDENTIFIER CMP_EQUAL STRING
+ IDENTIFIER '.' IDENTIFIER op STRING
{
- $$ = sdb_store_matcher_parse_cmp($1, $3, "=", $5);
- /* TODO: simplify memory management in the parser */
+ $$ = sdb_store_matcher_parse_cmp($1, $3, $4, $5);
free($1); $1 = NULL;
free($3); $3 = NULL;
free($5); $5 = NULL;
}
+ ;
+
+op:
+ CMP_EQUAL { $$ = "="; }
|
- IDENTIFIER '.' IDENTIFIER CMP_NEQUAL STRING
- {
- $$ = sdb_store_matcher_parse_cmp($1, $3, "!=", $5);
- /* TODO: simplify memory management in the parser */
- free($1); $1 = NULL;
- free($3); $3 = NULL;
- free($5); $5 = NULL;
- }
+ CMP_NEQUAL { $$ = "!="; }
|
- IDENTIFIER '.' IDENTIFIER CMP_REGEX STRING
- {
- $$ = sdb_store_matcher_parse_cmp($1, $3, "=~", $5);
- free($1); $1 = NULL;
- free($3); $3 = NULL;
- free($5); $5 = NULL;
- }
+ CMP_REGEX { $$ = "=~"; }
|
- IDENTIFIER '.' IDENTIFIER CMP_NREGEX STRING
- {
- $$ = sdb_store_matcher_parse_cmp($1, $3, "!~", $5);
- free($1); $1 = NULL;
- free($3); $3 = NULL;
- free($5); $5 = NULL;
- }
+ CMP_NREGEX { $$ = "!~"; }
;
%%