summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d1559e5)
raw | patch | inline | side by side (parent: d1559e5)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 23 Oct 2014 19:30:00 +0000 (21:30 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 23 Oct 2014 20:03:29 +0000 (22:03 +0200) |
src/frontend/grammar.y | patch | blob | history | |
t/unit/frontend/parser_test.c | patch | blob | history |
diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 435b24719f3ad09173edd9463df6f664ce727c71..3c813dcddb05d6ff54ac4a1d93fde958f4afab08 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
|
IDENTIFIER cmp expression
{
- $$ = sdb_store_matcher_parse_cmp($1, $2, $3);
+ int type = sdb_store_parse_object_type($1);
+ sdb_store_expr_t *e = sdb_store_expr_fieldvalue(SDB_FIELD_NAME);
+ sdb_store_matcher_op_cb cb = sdb_store_parse_matcher_op($2);
+ sdb_store_matcher_t *m;
+ assert(cb);
+
+ m = cb(e, $3);
+ /* TODO: this only works as long as queries
+ * are limited to hosts */
+ if (type == SDB_HOST) {
+ $$ = m;
+ }
+ else {
+ $$ = sdb_store_child_matcher(type, m);
+ sdb_object_deref(SDB_OBJ(m));
+ }
+
free($1); $1 = NULL;
sdb_object_deref(SDB_OBJ($3));
+ sdb_object_deref(SDB_OBJ(e));
}
|
expression IS NULL_T
index e251d7116e73c350c44afa124436219b72b02d12..6b9e86e95fd44d70d714276088c016ce9e577ed9 100644 (file)
{ "", -1, -1 },
/* valid expressions */
- { "host = 'localhost'", -1, MATCHER_NAME },
- { "host != 'localhost'", -1, MATCHER_NOT },
- { "host =~ 'host'", -1, MATCHER_NAME },
- { "host !~ 'host'", -1, MATCHER_NOT },
- { "host = 'localhost' -- foo", -1, MATCHER_NAME },
- { "host = 'host' <garbage>", 13, MATCHER_NAME },
+ { "host = 'localhost'", -1, MATCHER_EQ },
+ { "host != 'localhost'", -1, MATCHER_NE },
+ { "host =~ 'host'", -1, MATCHER_REGEX },
+ { "host !~ 'host'", -1, MATCHER_NREGEX },
+ { "host = 'localhost' -- foo", -1, MATCHER_EQ },
+ { "host = 'host' <garbage>", 13, MATCHER_EQ },
/* match hosts by service */
- { "service = 'name'", -1, MATCHER_NAME },
- { "service != 'name'", -1, MATCHER_NOT },
- { "service =~ 'pattern'", -1, MATCHER_NAME },
- { "service !~ 'pattern'", -1, MATCHER_NOT },
+ { "service = 'name'", -1, MATCHER_SERVICE },
+ { "service != 'name'", -1, MATCHER_SERVICE },
+ { "service =~ 'pattern'", -1, MATCHER_SERVICE },
+ { "service !~ 'pattern'", -1, MATCHER_SERVICE },
+ /* match hosts by metric */
+ { "metric = 'name'", -1, MATCHER_METRIC },
+ { "metric != 'name'", -1, MATCHER_METRIC },
+ { "metric =~ 'pattern'", -1, MATCHER_METRIC },
+ { "metric !~ 'pattern'", -1, MATCHER_METRIC },
/* match hosts by attribute */
- { "attribute = 'name'", -1, MATCHER_NAME },
- { "attribute != 'name'", -1, MATCHER_NOT },
- { "attribute =~ 'pattern'", -1, MATCHER_NAME },
- { "attribute !~ 'pattern'", -1, MATCHER_NOT },
+ { "attribute = 'name'", -1, MATCHER_ATTRIBUTE },
+ { "attribute != 'name'", -1, MATCHER_ATTRIBUTE },
+ { "attribute =~ 'pattern'", -1, MATCHER_ATTRIBUTE },
+ { "attribute !~ 'pattern'", -1, MATCHER_ATTRIBUTE },
/* composite expressions */
{ "host =~ 'pattern' AND "
"service =~ 'pattern'", -1, MATCHER_AND },