fix for associating current scope with the name of enums; name tidying

This commit is contained in:
Vern Paxson 2021-03-18 08:58:03 -07:00
parent b3ee7ec675
commit e407d8ab51

View file

@ -143,18 +143,21 @@ static zeek::detail::Location func_hdr_location;
zeek::EnumType* cur_enum_type = nullptr; zeek::EnumType* cur_enum_type = nullptr;
static zeek::detail::ID* cur_decl_type_id = nullptr; static zeek::detail::ID* cur_decl_type_id = nullptr;
static void parser_new_enum (void) static void parse_new_enum (void)
{ {
/* Starting a new enum definition. */ /* Starting a new enum definition. */
assert(cur_enum_type == nullptr); assert(cur_enum_type == nullptr);
if ( cur_decl_type_id ) if ( cur_decl_type_id )
cur_enum_type = new zeek::EnumType(cur_decl_type_id->Name()); {
auto name = zeek::detail::make_full_var_name(current_module.c_str(), cur_decl_type_id->Name());
cur_enum_type = new zeek::EnumType(name);
}
else else
zeek::reporter->FatalError("incorrect syntax for enum type declaration"); zeek::reporter->FatalError("incorrect syntax for enum type declaration");
} }
static void parser_redef_enum (zeek::detail::ID *id) static void parse_redef_enum (zeek::detail::ID* id)
{ {
/* Redef an enum. id points to the enum to be redefined. /* Redef an enum. id points to the enum to be redefined.
Let cur_enum_type point to it. */ Let cur_enum_type point to it. */
@ -958,7 +961,7 @@ type:
$$ = 0; $$ = 0;
} }
| TOK_ENUM '{' { zeek::detail::set_location(@1); parser_new_enum(); } enum_body '}' | TOK_ENUM '{' { zeek::detail::set_location(@1); parse_new_enum(); } enum_body '}'
{ {
zeek::detail::set_location(@1, @5); zeek::detail::set_location(@1, @5);
$4->UpdateLocationEndInfo(@5); $4->UpdateLocationEndInfo(@5);
@ -1151,7 +1154,7 @@ decl:
} }
| TOK_REDEF TOK_ENUM global_id TOK_ADD_TO '{' | TOK_REDEF TOK_ENUM global_id TOK_ADD_TO '{'
{ ++in_enum_redef; parser_redef_enum($3); zeek::detail::zeekygen_mgr->Redef($3, ::filename); } { ++in_enum_redef; parse_redef_enum($3); zeek::detail::zeekygen_mgr->Redef($3, ::filename); }
enum_body '}' ';' enum_body '}' ';'
{ {
--in_enum_redef; --in_enum_redef;