summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0503c3c)
raw | patch | inline | side by side (parent: 0503c3c)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 6 Apr 2014 17:57:07 +0000 (19:57 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 6 Apr 2014 17:57:07 +0000 (19:57 +0200) |
src/frontend/grammar.y | patch | blob | history | |
src/frontend/scanner.l | patch | blob | history | |
t/frontend/parser_test.c | patch | blob | history |
diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 858c766b698aa124308a292f8ddcf90250127120..1cf068538bc13f7686fc12df2d0ba22247f9d553 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
if ((M(m)->type == MATCHER_HOST)
|| (M(m)->type == MATCHER_AND)
- || (M(m)->type == MATCHER_OR))
+ || (M(m)->type == MATCHER_OR)
+ || (M(m)->type == MATCHER_NOT))
CONN_MATCHER($$)->matcher = m;
else if (M(m)->type == MATCHER_SERVICE)
CONN_MATCHER($$)->matcher = sdb_store_host_matcher(NULL,
diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l
index 32c13c54c355865d4024e94f683a06b6330b9492..dd2a86cf5273b4e5e3c450c02306820b282a1a46 100644 (file)
--- a/src/frontend/scanner.l
+++ b/src/frontend/scanner.l
return LIST;
else if (! strcasecmp(yytext, "LOOKUP"))
return LOOKUP;
+ else if (! strcasecmp(yytext, "NOT"))
+ return NOT;
else if (! strcasecmp(yytext, "OR"))
return OR;
else if (! strcasecmp(yytext, "WHERE"))
index ffeca8f68b091d50e5c90c5d165edf2867986b1f..74075b3a6c8de866840891e52d975fdc0fdc35ba 100644 (file)
--- a/t/frontend/parser_test.c
+++ b/t/frontend/parser_test.c
{ "LOOKUP hosts WHERE "
"host.name = 'host'", -1, 1, CONNECTION_LOOKUP },
+ { "LOOKUP hosts WHERE NOT "
+ "host.name = 'host'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts WHERE "
"host.name =~ 'p' AND "
"service.name =~ 'p'", -1, 1, CONNECTION_LOOKUP },
+ { "LOOKUP hosts WHERE NOT "
+ "host.name =~ 'p' AND "
+ "service.name =~ 'p'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts WHERE "
"host.name =~ 'p' AND "
"service.name =~ 'p' OR "
"service.name =~ 'r'", -1, 1, CONNECTION_LOOKUP },
+ { "LOOKUP hosts WHERE NOT "
+ "host.name =~ 'p' AND "
+ "service.name =~ 'p' OR "
+ "service.name =~ 'r'", -1, 1, CONNECTION_LOOKUP },
/* comments */
{ "/* some comment */", -1, 0, 0 },
"service.name =~ 'pattern'", -1, MATCHER_AND },
{ "host.name =~ 'pattern' OR "
"service.name =~ 'pattern'", -1, MATCHER_OR },
+ { "NOT host.name = 'host'", -1, MATCHER_NOT },
/* check operator precedence */
{ "host.name = 'name' OR "
"service.name = 'name') AND "
"(attribute.name = 'name' OR "
"attribute.foo = 'bar')", -1, MATCHER_AND },
+ { "NOT host.name = 'name' OR "
+ "service.name = 'name'", -1, MATCHER_OR },
+ { "NOT host.name = 'name' OR "
+ "NOT service.name = 'name'", -1, MATCHER_OR },
+ { "NOT (host.name = 'name' OR "
+ "NOT service.name = 'name')", -1, MATCHER_NOT },
/* syntax errors */
{ "LIST", -1, -1 },