aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dfilter/grammar.lemon
diff options
context:
space:
mode:
authorJeffrey Smith <whydoubt@gmail.com>2015-08-18 22:03:41 -0500
committerAnders Broman <a.broman58@gmail.com>2015-09-11 06:31:33 +0000
commit80322d88da92969c170c915e93a33a96e12497a7 (patch)
tree516e0c526cda1291b5c2a376d40f4fb80b6ddc98 /epan/dfilter/grammar.lemon
parent86d8b8d7bfd3c76d646907d5549e552519ea8261 (diff)
dfilter: Add membership operator
Added a new relational test: 'x in {a b c}'. The only LHS entity supported at this time is a field. The generated DFVM operations are equivalent to an OR'ed series of =='s, but with the redundant existence tests removed. Change-Id: Iddc89b81cf7ad6319aef1a2a94f93314cb721a8a Reviewed-on: https://code.wireshark.org/review/10246 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dfilter/grammar.lemon')
-rw-r--r--epan/dfilter/grammar.lemon24
1 files changed, 24 insertions, 0 deletions
diff --git a/epan/dfilter/grammar.lemon b/epan/dfilter/grammar.lemon
index 872a0d61c7..d3bab21ed5 100644
--- a/epan/dfilter/grammar.lemon
+++ b/epan/dfilter/grammar.lemon
@@ -9,6 +9,7 @@
#include "sttype-range.h"
#include "sttype-test.h"
#include "sttype-function.h"
+#include "sttype-set.h"
#include "drange.h"
#include "grammar.h"
@@ -61,6 +62,9 @@
%type funcparams {GSList*}
%destructor funcparams {st_funcparams_free($$);}
+%type setnode_list {GSList*}
+%destructor setnode_list {set_nodelist_free($$);}
+
/* This is called as soon as a syntax error happens. After that,
any "error" symbols are shifted, if possible. */
%syntax_error {
@@ -98,6 +102,9 @@ any "error" symbols are shifted, if possible. */
case STTYPE_FUNCTION:
dfilter_fail(dfw, "The function s was unexpected in this context.");
break;
+ case STTYPE_SET:
+ dfilter_fail(dfw, "Syntax error, SET.");
+ break;
/* These aren't handed to use as terminal tokens from
the scanner, so was can assert that we'll never
@@ -285,6 +292,23 @@ rel_op2(O) ::= TEST_BITWISE_AND. { O = TEST_OP_BITWISE_AND; }
rel_op2(O) ::= TEST_CONTAINS. { O = TEST_OP_CONTAINS; }
rel_op2(O) ::= TEST_MATCHES. { O = TEST_OP_MATCHES; }
+relation_test(T) ::= entity(E) TEST_IN LBRACE setnode_list(L) RBRACE.
+{
+ stnode_t *S;
+ T = stnode_new(STTYPE_TEST, NULL);
+ S = stnode_new(STTYPE_SET, L);
+ sttype_test_set2(T, TEST_OP_IN, E, S);
+}
+
+setnode_list(L) ::= entity(E).
+{
+ L = g_slist_append(NULL, E);
+}
+
+setnode_list(L) ::= setnode_list(P) entity(E).
+{
+ L = g_slist_append(P, E);
+}
/* Functions */