summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2023-08-28 23:42:40 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2023-11-23 01:48:18 +0100
commit9198aa91255b5da29ea895d76858c1e8a1bf53bd (patch)
tree3322871b2e5c0c3daa5fafa552941dcef1fa19b9
parent788e495561d7bbc8b73f8f512328c567ee487478 (diff)
Filter: Add literal for generic empty list
Add literal for empty set "empty", which works for clist, eclist and lclist, by using existing constant promotion mechanism.
-rw-r--r--filter/config.Y1
-rw-r--r--filter/data.h1
-rw-r--r--filter/decl.m49
3 files changed, 11 insertions, 0 deletions
diff --git a/filter/config.Y b/filter/config.Y
index f3ed2dc5..bf5d5639 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -933,6 +933,7 @@ term:
| term_dot_method
+ | EMPTY { $$ = f_new_inst(FI_CONSTANT, val_empty(T_EMPTY_LIST); }
| '+' EMPTY '+' { $$ = f_new_inst(FI_CONSTANT, val_empty(T_PATH)); }
| '-' EMPTY '-' { $$ = f_new_inst(FI_CONSTANT, val_empty(T_CLIST)); }
| '-' '-' EMPTY '-' '-' { $$ = f_new_inst(FI_CONSTANT, val_empty(T_ECLIST)); }
diff --git a/filter/data.h b/filter/data.h
index 21a78bf6..9f9bf4ca 100644
--- a/filter/data.h
+++ b/filter/data.h
@@ -20,6 +20,7 @@
enum f_type {
/* Nothing. Simply nothing. */
T_VOID = 0,
+ T_EMPTY_LIST = 1,
T_NONE = 1, /* Special hack to represent missing arguments */
diff --git a/filter/decl.m4 b/filter/decl.m4
index 57bf9454..d5fa64dc 100644
--- a/filter/decl.m4
+++ b/filter/decl.m4
@@ -594,6 +594,15 @@ f_const_promotion_(struct f_inst *arg, enum f_type want, int update)
if (update)
*c = f_const_empty_prefix_set;
return 1;
+ } else if ((c->type == T_EMPTY_LIST) && (want == T_CLIST)) {
+ *c = f_const_empty_clist;
+ return 1;
+ } else if ((c->type == T_EMPTY_LIST) && (want == T_ECLIST)) {
+ *c = f_const_empty_eclist;
+ return 1;
+ } else if ((c->type == T_EMPTY_LIST) && (want == T_LCLIST)) {
+ *c = f_const_empty_lclist;
+ return 1;
}
return 0;