mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
"add" and "delete" are now expressions rather than statements
This commit is contained in:
parent
e9a0a50da5
commit
0e5bece385
5 changed files with 138 additions and 42 deletions
30
src/parse.y
30
src/parse.y
|
@ -37,7 +37,7 @@
|
|||
%token TOK_NO_TEST
|
||||
|
||||
%left ','
|
||||
%right '=' TOK_ADD_TO TOK_REMOVE_FROM
|
||||
%right '=' TOK_ADD_TO TOK_REMOVE_FROM TOK_ADD TOK_DELETE
|
||||
%right '?' ':'
|
||||
%left TOK_OR_OR
|
||||
%left TOK_AND_AND
|
||||
|
@ -508,6 +508,18 @@ expr:
|
|||
$$ = new CloneExpr({AdoptRef{}, $3});
|
||||
}
|
||||
|
||||
| TOK_ADD expr
|
||||
{
|
||||
set_location(@1, @2);
|
||||
$$ = new AggrAddExpr({AdoptRef{}, $2});
|
||||
}
|
||||
|
||||
| TOK_DELETE expr
|
||||
{
|
||||
set_location(@1, @2);
|
||||
$$ = new AggrDelExpr({AdoptRef{}, $2});
|
||||
}
|
||||
|
||||
| TOK_INCR expr
|
||||
{
|
||||
set_location(@1, @2);
|
||||
|
@ -1934,22 +1946,6 @@ stmt:
|
|||
script_coverage_mgr.AddStmt($$);
|
||||
}
|
||||
|
||||
| TOK_ADD expr ';' opt_no_test
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new AddStmt({AdoptRef{}, $2});
|
||||
if ( ! $4 )
|
||||
script_coverage_mgr.AddStmt($$);
|
||||
}
|
||||
|
||||
| TOK_DELETE expr ';' opt_no_test
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new DelStmt({AdoptRef{}, $2});
|
||||
if ( ! $4 )
|
||||
script_coverage_mgr.AddStmt($$);
|
||||
}
|
||||
|
||||
| TOK_LOCAL local_id opt_type init_class opt_init opt_attr ';' opt_no_test
|
||||
{
|
||||
set_location(@1, @7);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue