Skip to content

Commit

Permalink
filterx: add unset()/isset() grammar
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Szakacs <[email protected]>
  • Loading branch information
alltilla authored and bazsi committed Apr 9, 2024
1 parent 13a7a7e commit f437c4d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/filterx/expr-isset.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "filterx/expr-isset.h"
#include "filterx/object-primitive.h"

FilterXObject *
static FilterXObject *
_eval(FilterXExpr *s)
{
FilterXUnaryOp *self = (FilterXUnaryOp *) s;
Expand Down
2 changes: 1 addition & 1 deletion lib/filterx/expr-unset.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "filterx/expr-unset.h"
#include "filterx/object-primitive.h"

FilterXObject *
static FilterXObject *
_eval(FilterXExpr *s)
{
FilterXUnaryOp *self = (FilterXUnaryOp *) s;
Expand Down
6 changes: 6 additions & 0 deletions lib/filterx/filterx-grammar.ym
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 <ptr> stmts
%type <node> stmt
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/filterx/filterx-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ static CfgLexerKeyword filterx_keywords[] =
{ "else", KW_ELSE },
{ "elif", KW_ELIF },

{ "isset", KW_ISSET },
{ "unset", KW_UNSET },

{ CFG_KEYWORD_STOP },
};

Expand Down

0 comments on commit f437c4d

Please sign in to comment.