diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 85fe8c4a108b6a34864b6e778a851664ecfdd053..92bfd1f5c60d2ab24d5e0b6f82b90e7e4ce73c71 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
%token SCANNER_ERROR
-%token AND OR IS NOT MATCHING
+%token AND OR IS NOT MATCHING FILTER
%token CMP_EQUAL CMP_NEQUAL CMP_REGEX CMP_NREGEX
%token CMP_LT CMP_LE CMP_GE CMP_GT
%token CONCAT
;
/*
- * LOOKUP <type> MATCHING <condition>;
+ * LOOKUP <type> MATCHING <condition> [FILTER <condition>];
*
* Returns detailed information about <type> matching condition.
*/
$$->cmd = CONNECTION_LOOKUP;
free($2); $2 = NULL;
}
+ |
+ LOOKUP IDENTIFIER MATCHING condition FILTER condition
+ {
+ /* TODO: support other types as well */
+ if (strcasecmp($2, "hosts")) {
+ char errmsg[strlen($2) + 32];
+ snprintf(errmsg, sizeof(errmsg),
+ YY_("unknown table %s"), $2);
+ sdb_fe_yyerror(&yylloc, scanner, errmsg);
+ free($2); $2 = NULL;
+ sdb_object_deref(SDB_OBJ($4));
+ YYABORT;
+ }
+
+ $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL,
+ conn_lookup_t, conn_lookup_destroy));
+ CONN_LOOKUP($$)->matcher = CONN_MATCHER($4);
+ CONN_LOOKUP($$)->filter = CONN_MATCHER($6);
+ $$->cmd = CONNECTION_LOOKUP;
+ free($2); $2 = NULL;
+ }
;
condition:
}
$$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL,
- conn_node_matcher_t, conn_matcher_destroy));
+ conn_matcher_t, conn_matcher_destroy));
$$->cmd = CONNECTION_EXPR;
CONN_MATCHER($$)->matcher = $1;
}
* Parse matchers comparing object attributes with a value.
*/
compare_matcher:
+ ':' IDENTIFIER op expression
+ {
+ $$ = sdb_store_matcher_parse_field_cmp($2, $3, $4);
+ free($2); $2 = NULL;
+ sdb_object_deref(SDB_OBJ($4));
+ }
+ |
IDENTIFIER op expression
{
$$ = sdb_store_matcher_parse_cmp($1, NULL, $2, $3);