diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 92b55ebbd509eb9d62c975a3866c5aa67ce07534..fed30d238f613fe92f301bd3a5ae695d26a10d9f 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
* private helper functions
*/
-static sdb_store_matcher_t *
-name_matcher(const char *type_name, const char *cmp, sdb_store_expr_t *expr);
-
static sdb_store_matcher_t *
name_iter_matcher(int m_type, const char *type_name, const char *cmp,
sdb_store_expr_t *expr);
sdb_object_deref(SDB_OBJ($3));
}
|
- IDENTIFIER cmp expression
- {
- $$ = name_matcher($1, $2, $3);
- free($1); $1 = NULL;
- sdb_object_deref(SDB_OBJ($3));
- }
- |
ANY IDENTIFIER cmp expression
{
$$ = name_iter_matcher(MATCHER_ANY, $2, $3, $4);
sdb_object_deref(SDB_OBJ($3)); $3 = NULL;
}
|
- '.' IDENTIFIER
+ IDENTIFIER
{
- int field = sdb_store_parse_field_name($2);
- free($2); $2 = NULL;
+ int field;
+ /* TODO: this only works as long as queries
+ * are limited to hosts */
+ if (!strcasecmp($1, "host"))
+ field = SDB_FIELD_NAME;
+ else
+ field = sdb_store_parse_field_name($1);
+ free($1); $1 = NULL;
$$ = sdb_store_expr_fieldvalue(field);
}
|
sdb_log(SDB_LOG_ERR, "frontend: parse error: %s", msg);
} /* sdb_fe_yyerror */
-static sdb_store_matcher_t *
-name_matcher(const char *type_name, const char *cmp, sdb_store_expr_t *expr)
-{
- int type = sdb_store_parse_object_type(type_name);
- sdb_store_matcher_op_cb cb = sdb_store_parse_matcher_op(cmp);
- sdb_store_expr_t *e;
- sdb_store_matcher_t *m;
- assert(cb);
-
- /* TODO: this only works as long as queries
- * are limited to hosts */
- if (type != SDB_HOST)
- return NULL;
-
- e = sdb_store_expr_fieldvalue(SDB_FIELD_NAME);
- m = cb(e, expr);
- sdb_object_deref(SDB_OBJ(e));
- return m;
-} /* name_matcher */
-
static sdb_store_matcher_t *
name_iter_matcher(int m_type, const char *type_name, const char *cmp,
sdb_store_expr_t *expr)