"add" and "delete" are now expressions rather than statements

This commit is contained in:
Vern Paxson 2024-05-16 14:34:51 -07:00 committed by Tim Wojtulewicz
parent e9a0a50da5
commit 0e5bece385
5 changed files with 138 additions and 42 deletions

View file

@ -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);