From 7491cdbd1dcb6e9bad2517b727cbfe7e8c05632d Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Mon, 25 Nov 2024 15:14:27 +0100 Subject: [PATCH] Filter: multi-command case branches now need braces. Removing an exception from the otherwise quite systematic syntax. Closes #111. --- doc/bird.sgml | 6 +++--- doc/migration-bird3.md | 5 +++++ filter/config.Y | 12 ++++-------- filter/test.conf | 3 +++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index 3e7ae9dd..da887b1e 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -1974,8 +1974,8 @@ and name is used). In both cases, it must have the same type as elements. . The expression after case can be of any type which can be on the left side of the ˜ operator and anything that could be a member of -a set is allowed before matches one of the matches one of the matches neither of the cmds_int cmd_prep -%type term term_bs cmd cmd_var cmds cmds_scoped constant constructor var var_list var_list_r function_call bgp_path_expr bgp_path bgp_path_tail term_dot_method method_name_cont +%type term term_bs cmd cmd_var cmds constant constructor var var_list var_list_r function_call bgp_path_expr bgp_path bgp_path_tail term_dot_method method_name_cont %type static_attr %type filter where_filter %type filter_body function_body @@ -625,8 +625,6 @@ cmds: /* EMPTY */ { $$ = NULL; } | cmds_int { $$ = $1.begin; } ; -cmds_scoped: { cf_push_soft_scope(new_config); } cmds { cf_pop_soft_scope(new_config); $$ = $2; } ; - cmd_var: var | cmd ; cmd_prep: cmd_var { @@ -781,14 +779,14 @@ fprefix_set: ; switch_body: /* EMPTY */ { $$ = NULL; } - | switch_body switch_items ':' cmds_scoped { + | switch_body switch_items ':' cmd { /* Fill data fields */ struct f_tree *t; for (t = $2; t; t = t->left) t->data = $4; $$ = f_merge_items($1, $2); } - | switch_body ELSECOL cmds_scoped { + | switch_body ELSECOL cmd { struct f_tree *t = f_new_tree(); t->from.type = t->to.type = T_VOID; t->right = t; @@ -990,9 +988,7 @@ for_var: ; cmd: - '{' cmds_scoped '}' { - $$ = $2; - } + '{' { cf_push_soft_scope(new_config); } cmds { cf_pop_soft_scope(new_config); } '}' { $$ = $3; } | IF term THEN cmd { $$ = f_new_inst(FI_CONDITION, $2, $4, NULL); } diff --git a/filter/test.conf b/filter/test.conf index f27ad0b7..24094e80 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -195,8 +195,11 @@ bt_test_suite(t_bool, "Testing boolean expressions"); function aux_t_int(int t; int u) { + int v; case t { 1: {} + 2: { int u; u = 1; v = 42; } + 3: if true then v = t + u + 53; else v = 35 + u + t; else: {} } }