From 65c187e30be0983b285e3bd66f3087e624a71cfe Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Fri, 5 Apr 2024 12:03:32 +0200 Subject: [PATCH] filterx: remove "fx" prefix from conditional rules for consistency Signed-off-by: Balazs Scheidler --- lib/filterx/filterx-grammar.ym | 46 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/filterx/filterx-grammar.ym b/lib/filterx/filterx-grammar.ym index 605afe13088..56c67ba5fe7 100644 --- a/lib/filterx/filterx-grammar.ym +++ b/lib/filterx/filterx-grammar.ym @@ -106,9 +106,9 @@ construct_template_expr(LogTemplate *template) %type list_values %type list_value %type boolean -%type fxcondition -%type fxif -%type fxcodeblock +%type conditional +%type if +%type codeblock %type tenary %% @@ -124,7 +124,7 @@ stmts stmt : expr ';' { $$ = $1; } - | fxcondition ';' { $$ = $1; } + | conditional ';' { $$ = $1; } ; expr @@ -267,32 +267,36 @@ list_value | list_expr_inner { $$ = $1; } ; -fxcondition - : fxif { $$ = $1; } - | fxif KW_ELSE fxcodeblock { - $$ = filterx_conditional_add_false_branch((FilterXConditional*)$1, (FilterXConditional*)filterx_conditional_new_codeblock($3)); - } +conditional + : if { $$ = $1; } + | if KW_ELSE codeblock + { + $$ = filterx_conditional_add_false_branch((FilterXConditional*)$1, (FilterXConditional*)filterx_conditional_new_codeblock($3)); + } ; -fxif - : KW_IF '(' expr ')' fxcodeblock { - $$ = filterx_conditional_new_conditional_codeblock($3, $5); - } - | fxif KW_ELIF '(' expr ')' fxcodeblock { - $$ = filterx_conditional_add_false_branch((FilterXConditional*)$1, (FilterXConditional*)filterx_conditional_new_conditional_codeblock($4, $6)); - } +if + : KW_IF '(' expr ')' codeblock + { + $$ = filterx_conditional_new_conditional_codeblock($3, $5); + } + | if KW_ELIF '(' expr ')' codeblock + { + $$ = filterx_conditional_add_false_branch((FilterXConditional*)$1, (FilterXConditional*)filterx_conditional_new_conditional_codeblock($4, $6)); + } ; -fxcodeblock +codeblock : '{' stmts '}' { $$ = $2; } ; tenary - : '(' expr '?' expr ':' expr ')' { - FilterXConditional *cond = (FilterXConditional*)filterx_conditional_new_conditional_codeblock($2, g_list_append(NULL, $4)); - $$ = filterx_conditional_add_false_branch(cond, (FilterXConditional*)filterx_conditional_new_codeblock(g_list_append(NULL, $6))); - } + : '(' expr '?' expr ':' expr ')' + { + FilterXConditional *cond = (FilterXConditional*)filterx_conditional_new_conditional_codeblock($2, g_list_append(NULL, $4)); + $$ = filterx_conditional_add_false_branch(cond, (FilterXConditional*)filterx_conditional_new_codeblock(g_list_append(NULL, $6))); + } ; /* INCLUDE_RULES */