mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/vern/field-assign-parsing'
* origin/topic/vern/field-assign-parsing: tightened up parsing of $field=X record constructor expressions
This commit is contained in:
commit
42f7a2d88c
6 changed files with 56 additions and 23 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
8.1.0-dev.496 | 2025-09-03 16:17:23 -0400
|
||||||
|
|
||||||
|
* tightened up parsing of $field=X record constructor expressions (Vern Paxson, Corelight)
|
||||||
|
|
||||||
8.1.0-dev.494 | 2025-09-03 14:50:12 +0200
|
8.1.0-dev.494 | 2025-09-03 14:50:12 +0200
|
||||||
|
|
||||||
* Remove unnecessary peer signature from test `scripts.base.protocols.bittorrent.tracker` (Benjamin Bannier, Corelight)
|
* Remove unnecessary peer signature from test `scripts.base.protocols.bittorrent.tracker` (Benjamin Bannier, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
8.1.0-dev.494
|
8.1.0-dev.496
|
||||||
|
|
63
src/parse.y
63
src/parse.y
|
@ -61,7 +61,7 @@
|
||||||
%type <id_l> local_id_list case_type_list
|
%type <id_l> local_id_list case_type_list
|
||||||
%type <ic> init_class
|
%type <ic> init_class
|
||||||
%type <val> TOK_CONSTANT
|
%type <val> TOK_CONSTANT
|
||||||
%type <expr> expr opt_expr rhs opt_init anonymous_function lambda_body index_slice opt_deprecated when_condition
|
%type <expr> expr opt_expr rhs opt_init anonymous_function lambda_body index_slice opt_deprecated when_condition field_assign
|
||||||
%type <event_expr> event
|
%type <event_expr> event
|
||||||
%type <stmt> stmt stmt_list func_body for_head
|
%type <stmt> stmt stmt_list func_body for_head
|
||||||
%type <type> simple_type type opt_type enum_body
|
%type <type> simple_type type opt_type enum_body
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
%type <type_decl> type_decl formal_args_decl
|
%type <type_decl> type_decl formal_args_decl
|
||||||
%type <type_decl_l> type_decl_list formal_args_decl_list
|
%type <type_decl_l> type_decl_list formal_args_decl_list
|
||||||
%type <record> formal_args
|
%type <record> formal_args
|
||||||
%type <list> expr_list opt_expr_list rhs_expr_list
|
%type <list> expr_list opt_expr_list rhs_expr_list opt_exprs_or_field_assigns field_assigns
|
||||||
%type <c_case> case
|
%type <c_case> case
|
||||||
%type <case_l> case_list
|
%type <case_l> case_list
|
||||||
%type <attr> attr
|
%type <attr> attr
|
||||||
|
@ -756,22 +756,6 @@ expr:
|
||||||
$$ = new FieldExpr({AdoptRef{}, $1}, $3);
|
$$ = new FieldExpr({AdoptRef{}, $1}, $3);
|
||||||
}
|
}
|
||||||
|
|
||||||
| '$' TOK_ID '=' expr
|
|
||||||
{
|
|
||||||
set_location(@1, @4);
|
|
||||||
$$ = new FieldAssignExpr($2, {AdoptRef{}, $4});
|
|
||||||
}
|
|
||||||
|
|
||||||
| '$' TOK_ID begin_lambda '='
|
|
||||||
{
|
|
||||||
func_hdr_location = @1;
|
|
||||||
$3->SetInferReturnType(true);
|
|
||||||
}
|
|
||||||
lambda_body
|
|
||||||
{
|
|
||||||
$$ = new FieldAssignExpr($2, IntrusivePtr{AdoptRef{}, $6});
|
|
||||||
}
|
|
||||||
|
|
||||||
| expr TOK_IN expr
|
| expr TOK_IN expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
|
@ -786,7 +770,7 @@ expr:
|
||||||
ExprPtr{AdoptRef{}, $3}));
|
ExprPtr{AdoptRef{}, $3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
| '[' opt_expr_list ']'
|
| '[' opt_exprs_or_field_assigns ']'
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
|
|
||||||
|
@ -810,7 +794,7 @@ expr:
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_RECORD '(' expr_list ')'
|
| TOK_RECORD '(' field_assigns expr_list_opt_comma ')'
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new RecordConstructorExpr({AdoptRef{}, $3});
|
$$ = new RecordConstructorExpr({AdoptRef{}, $3});
|
||||||
|
@ -843,7 +827,7 @@ expr:
|
||||||
++in_init;
|
++in_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt_expr_list
|
opt_exprs_or_field_assigns
|
||||||
{
|
{
|
||||||
if ( expr_is_table_type_name($1) )
|
if ( expr_is_table_type_name($1) )
|
||||||
--in_init;
|
--in_init;
|
||||||
|
@ -1018,6 +1002,43 @@ expr:
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
opt_exprs_or_field_assigns:
|
||||||
|
{ $$ = new ListExpr(); }
|
||||||
|
| expr_list expr_list_opt_comma
|
||||||
|
| field_assigns expr_list_opt_comma
|
||||||
|
;
|
||||||
|
|
||||||
|
field_assigns:
|
||||||
|
field_assigns ',' field_assign
|
||||||
|
{
|
||||||
|
set_location(@1, @3);
|
||||||
|
$1->Append({AdoptRef{}, $3});
|
||||||
|
}
|
||||||
|
| field_assign
|
||||||
|
{
|
||||||
|
set_location(@1);
|
||||||
|
expr_list_has_opt_comma = 0;
|
||||||
|
$$ = new ListExpr({AdoptRef{}, $1});
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
field_assign: '$' TOK_ID '=' expr
|
||||||
|
{
|
||||||
|
set_location(@1, @4);
|
||||||
|
$$ = new FieldAssignExpr($2, {AdoptRef{}, $4});
|
||||||
|
}
|
||||||
|
|
||||||
|
| '$' TOK_ID begin_lambda '='
|
||||||
|
{
|
||||||
|
func_hdr_location = @1;
|
||||||
|
$3->SetInferReturnType(true);
|
||||||
|
}
|
||||||
|
lambda_body
|
||||||
|
{
|
||||||
|
$$ = new FieldAssignExpr($2, IntrusivePtr{AdoptRef{}, $6});
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
rhs: '{' { ++in_init; } rhs_expr_list '}'
|
rhs: '{' { ++in_init; } rhs_expr_list '}'
|
||||||
{
|
{
|
||||||
--in_init;
|
--in_init;
|
||||||
|
|
2
testing/btest/Baseline/language.bogus-field-assign/out
Normal file
2
testing/btest/Baseline/language.bogus-field-assign/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/bogus-field-assign.zeek, line 6: syntax error, at or near "$"
|
|
@ -1,2 +1,2 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <...>/record-bad-ctor3.zeek, line 13: bad type in record constructor ([$x=a + 5, a + 9] and a + 9)
|
error in <...>/record-bad-ctor3.zeek, line 13: syntax error, at or near "a"
|
||||||
|
|
6
testing/btest/language/bogus-field-assign.zeek
Normal file
6
testing/btest/language/bogus-field-assign.zeek
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
# Zeek used to happily print the value of "5" here.
|
||||||
|
|
||||||
|
print $foo=5;
|
Loading…
Add table
Add a link
Reference in a new issue