Skip to content

Commit

Permalink
filterx: remove "fx" prefix from conditional rules for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <[email protected]>
  • Loading branch information
bazsi committed Apr 8, 2024
1 parent 83c998c commit 65c187e
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions lib/filterx/filterx-grammar.ym
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ construct_template_expr(LogTemplate *template)
%type <ptr> list_values
%type <ptr> list_value
%type <num> boolean
%type <ptr> fxcondition
%type <ptr> fxif
%type <ptr> fxcodeblock
%type <ptr> conditional
%type <ptr> if
%type <ptr> codeblock
%type <ptr> tenary

%%
Expand All @@ -124,7 +124,7 @@ stmts

stmt
: expr ';' { $$ = $1; }
| fxcondition ';' { $$ = $1; }
| conditional ';' { $$ = $1; }
;

expr
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 65c187e

Please sign in to comment.