mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Filter: multi-command case branches now need braces.
Removing an exception from the otherwise quite systematic syntax. Closes #111.
This commit is contained in:
parent
99fa1f01a4
commit
7491cdbd1d
@ -1974,8 +1974,8 @@ and name is used). In both cases, it must have the same type as elements.
|
||||
<m/expr/ { else: | <m/num_or_prefix [ .. num_or_prefix]/: <m/statement/ ; [
|
||||
... ] }</cf>. The expression after <cf>case</cf> 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 <cf/:/. Multiple commands are allowed without <cf/{}/
|
||||
grouping. If <cf><m/expr/</cf> matches one of the <cf/:/ clauses, statements
|
||||
a set is allowed before <cf/:/. Multiple commands must be grouped by <cf/{}/.
|
||||
If <cf><m/expr/</cf> matches one of the <cf/:/ clauses, statements
|
||||
between it and next <cf/:/ statement are executed. If <cf><m/expr/</cf> matches
|
||||
neither of the <cf/:/ clauses, the statements after <cf/else:/ are executed.
|
||||
|
||||
@ -1993,7 +1993,7 @@ for int asn in bgp_path do {
|
||||
}
|
||||
|
||||
case arg1 {
|
||||
2: print "two"; print "I can do more commands without {}";
|
||||
2: { print "two"; print "Multiple commands must brace themselves."; }
|
||||
3 .. 5: print "three to five";
|
||||
else: print "something else";
|
||||
}
|
||||
|
@ -60,6 +60,11 @@ the given prefix. Experimental.
|
||||
|
||||
Reload of filters is now done by `reload filters` command, contrary to just `reload` in BIRD 2.
|
||||
|
||||
## Filters
|
||||
|
||||
We have removed the exception for `case` where multiple commands could be written
|
||||
after the case label without braces. This caused unneeded complexity in the parser.
|
||||
|
||||
## Route attributes
|
||||
|
||||
All protocol attributes have been renamed in CLI to align with the filter language tokens.
|
||||
|
@ -381,7 +381,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
|
||||
%nonassoc ELSE
|
||||
|
||||
%type <xp> cmds_int cmd_prep
|
||||
%type <x> 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 <x> 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 <fsa> static_attr
|
||||
%type <f> filter where_filter
|
||||
%type <fl> 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);
|
||||
}
|
||||
|
@ -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: {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user