From f437c4d7efc77594cd0919015feadfddd347b1c4 Mon Sep 17 00:00:00 2001 From: Attila Szakacs Date: Wed, 3 Apr 2024 16:41:49 +0200 Subject: [PATCH] filterx: add unset()/isset() grammar Signed-off-by: Attila Szakacs --- lib/filterx/expr-isset.c | 2 +- lib/filterx/expr-unset.c | 2 +- lib/filterx/filterx-grammar.ym | 6 ++++++ lib/filterx/filterx-parser.c | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/filterx/expr-isset.c b/lib/filterx/expr-isset.c index 69c18d589c0..0186c382ab2 100644 --- a/lib/filterx/expr-isset.c +++ b/lib/filterx/expr-isset.c @@ -24,7 +24,7 @@ #include "filterx/expr-isset.h" #include "filterx/object-primitive.h" -FilterXObject * +static FilterXObject * _eval(FilterXExpr *s) { FilterXUnaryOp *self = (FilterXUnaryOp *) s; diff --git a/lib/filterx/expr-unset.c b/lib/filterx/expr-unset.c index 1ccee1b3f2d..669656147e4 100644 --- a/lib/filterx/expr-unset.c +++ b/lib/filterx/expr-unset.c @@ -24,7 +24,7 @@ #include "filterx/expr-unset.h" #include "filterx/object-primitive.h" -FilterXObject * +static FilterXObject * _eval(FilterXExpr *s) { FilterXUnaryOp *self = (FilterXUnaryOp *) s; diff --git a/lib/filterx/filterx-grammar.ym b/lib/filterx/filterx-grammar.ym index 56c67ba5fe7..c9eeab44977 100644 --- a/lib/filterx/filterx-grammar.ym +++ b/lib/filterx/filterx-grammar.ym @@ -49,6 +49,8 @@ #include "filterx/filterx-config.h" #include "filterx/expr-function.h" #include "filterx/expr-condition.h" +#include "filterx/expr-isset.h" +#include "filterx/expr-unset.h" #include "template/templates.h" @@ -84,6 +86,8 @@ construct_template_expr(LogTemplate *template) %token KW_TRUE, KW_FALSE %token KW_NULL %token KW_ENUM +%token KW_ISSET +%token KW_UNSET %type stmts %type stmt @@ -156,6 +160,8 @@ expr | expr KW_TAV_NE expr { $$ = filterx_comparison_new($1, $3, FCMPX_TYPE_AND_VALUE_BASED | FCMPX_NE ); } | '(' expr ')' { $$ = $2; } | tenary { $$ = $1; } + | KW_ISSET '(' expr ')' { $$ = filterx_isset_new($3); } + | KW_UNSET '(' expr ')' { $$ = filterx_unset_new($3); } ; expr_value diff --git a/lib/filterx/filterx-parser.c b/lib/filterx/filterx-parser.c index 1baa95a7b74..242978ae95e 100644 --- a/lib/filterx/filterx-parser.c +++ b/lib/filterx/filterx-parser.c @@ -48,6 +48,9 @@ static CfgLexerKeyword filterx_keywords[] = { "else", KW_ELSE }, { "elif", KW_ELIF }, + { "isset", KW_ISSET }, + { "unset", KW_UNSET }, + { CFG_KEYWORD_STOP }, };