diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 34a9c6b6474502d9fc059df45a6ed93a79890567..74e28dd837f7e8eb7a819e1a0a4ed2ebda032ffb 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
%token SCANNER_ERROR
-%token AND OR NOT WHERE
+%token AND OR IS NOT MATCHING
%token CMP_EQUAL CMP_NEQUAL CMP_REGEX CMP_NREGEX
%token CMP_LT CMP_LE CMP_GE CMP_GT
+/* NULL token */
+%token NULL_T
+
%token FETCH LIST LOOKUP
%token <str> IDENTIFIER STRING
%right NOT
%left CMP_EQUAL CMP_NEQUAL
%left CMP_LT CMP_LE CMP_GE CMP_GT
-%left CMP_REGEX CMP_NREGEX
+%nonassoc CMP_REGEX CMP_NREGEX
+%nonassoc IS
%left '(' ')'
%left '.'
;
/*
- * LOOKUP <type> WHERE <expression>;
+ * LOOKUP <type> MATCHING <expression>;
*
* Returns detailed information about <type> matching expression.
*/
lookup_statement:
- LOOKUP IDENTIFIER WHERE expression
+ LOOKUP IDENTIFIER MATCHING expression
{
/* TODO: support other types as well */
if (strcasecmp($2, "hosts")) {
* Parse matchers comparing object attributes with a value.
*/
compare_matcher:
+ IDENTIFIER op data
+ {
+ $$ = sdb_store_matcher_parse_cmp($1, NULL, $2, &$3);
+ free($1); $1 = NULL;
+ sdb_data_free_datum(&$3);
+ }
+ |
IDENTIFIER '.' IDENTIFIER op data
{
$$ = sdb_store_matcher_parse_cmp($1, $3, $4, &$5);
free($3); $3 = NULL;
sdb_data_free_datum(&$5);
}
+ |
+ IDENTIFIER '.' IDENTIFIER IS NULL_T
+ {
+ $$ = sdb_store_matcher_parse_cmp($1, $3, "IS", NULL);
+ free($1); $1 = NULL;
+ free($3); $3 = NULL;
+ }
+ |
+ IDENTIFIER '.' IDENTIFIER IS NOT NULL_T
+ {
+ sdb_store_matcher_t *m;
+ m = sdb_store_matcher_parse_cmp($1, $3, "IS", NULL);
+ free($1); $1 = NULL;
+ free($3); $3 = NULL;
+
+ /* sdb_store_inv_matcher return NULL if m==NULL */
+ $$ = sdb_store_inv_matcher(m);
+ sdb_object_deref(SDB_OBJ(m));
+ }
;
op: