mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Fix parsing of "local" named table constructors.
This commit is contained in:
parent
b1fd161274
commit
bf3c3887fd
3 changed files with 33 additions and 7 deletions
20
src/parse.y
20
src/parse.y
|
@ -207,6 +207,22 @@ static void extend_record(ID* id, type_decl_list* fields, attr_list* attrs)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool expr_is_table_type_name(const Expr* expr)
|
||||
{
|
||||
if ( expr->Tag() != EXPR_NAME )
|
||||
return false;
|
||||
|
||||
BroType* type = expr->Type();
|
||||
|
||||
if ( type->IsTable() )
|
||||
return true;
|
||||
|
||||
if ( type->Tag() == TYPE_TYPE )
|
||||
return type->AsTypeType()->Type()->IsTable();
|
||||
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
|
||||
%union {
|
||||
|
@ -538,13 +554,13 @@ expr:
|
|||
|
||||
| expr '('
|
||||
{
|
||||
if ( $1->Tag() == EXPR_NAME && $1->Type()->IsTable() )
|
||||
if ( expr_is_table_type_name($1) )
|
||||
++in_init;
|
||||
}
|
||||
|
||||
opt_expr_list
|
||||
{
|
||||
if ( $1->Tag() == EXPR_NAME && $1->Type()->IsTable() )
|
||||
if ( expr_is_table_type_name($1) )
|
||||
--in_init;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue