Skip to content

Commit

Permalink
Merge pull request #292 from alltilla/filterx-generator-as-func-param
Browse files Browse the repository at this point in the history
filterx: support passing generator to functions' not first param
  • Loading branch information
MrAnno authored Sep 18, 2024
2 parents 96ade8d + f703907 commit c74d445
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/filterx/filterx-grammar.ym
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ construct_template_expr(LogTemplate *template)
%type <node> generator_function_call
%type <node> function_call
%type <ptr> arguments
%type <ptr> argument
%type <ptr> first_argument
%type <ptr> rest_argument
%type <ptr> list_argument
%type <ptr> dict_argument
%type <node> literal
Expand Down Expand Up @@ -443,18 +444,24 @@ function_call
;

arguments
: arguments ',' argument { $$ = g_list_append($1, $3); }
| argument { $$ = g_list_append(NULL, $1); }
: arguments ',' rest_argument { $$ = g_list_append($1, $3); }
| first_argument { $$ = g_list_append(NULL, $1); }
| { $$ = NULL; }
;

argument
first_argument
: expr { $$ = filterx_function_arg_new(NULL, $1); }
| string KW_ASSIGN expr { $$ = filterx_function_arg_new($1, $3); free($1); }
| string KW_ASSIGN list_argument { $$ = filterx_function_arg_new($1, $3); free($1); }
| string KW_ASSIGN dict_argument { $$ = filterx_function_arg_new($1, $3); free($1); }
;

rest_argument
: first_argument
| dict_argument { $$ = filterx_function_arg_new(NULL, $1); }
| list_argument { $$ = filterx_function_arg_new(NULL, $1); }
;

list_argument
: list_generator {
GError *error = NULL;
Expand Down

0 comments on commit c74d445

Please sign in to comment.