From 440f2beec174a49e87a72382d989a2ecddbbc217 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 6 Sep 2026 17:29:50 -0700 Subject: [PATCH] Disambiguate let port names and types A let port can start with its name (`let l(T) = T;`) or a named type (`let l(T value) = value;`). Parse the optional type, name and dimensions together using the existing declaration rule. This is in preparation for removing TYPE_IDENTIFIER. Keep the explicit `untyped` alternative separate and remove the unused let_formal_type rule. Let declarations remain unsupported. Signed-off-by: Lars-Peter Clausen --- parse.y | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/parse.y b/parse.y index cedceccdf..89a33070c 100644 --- a/parse.y +++ b/parse.y @@ -1267,7 +1267,7 @@ Module::port_t *module_declare_interface_port(const YYLTYPE&loc, char *type, %type data_type data_type_opt data_type_or_implicit data_type_or_implicit_or_void %type block_reg_data_type for_decl_data_type %type implicit_type -%type reg_prefixed_atomic_type let_formal_type +%type reg_prefixed_atomic_type %type packed_array_data_type atomic_type %type ps_type_identifier ps_type_identifier_dim @@ -6088,17 +6088,16 @@ let_port_list // FIXME: What about the attributes? let_port_item - : attribute_list_opt let_formal_type IDENTIFIER dimensions_opt initializer_opt - { perm_string tmp3 = lex_strings.make($3); - $$ = pform_make_let_port($2, tmp3, $4, $5); + : attribute_list_opt data_type_or_implicit_plus_id_dim initializer_opt + { perm_string tmp2 = lex_strings.make($2.id); + $$ = pform_make_let_port($2.type, tmp2, $2.ranges, $3); + delete[]$2.id; + } + | attribute_list_opt K_untyped IDENTIFIER dimensions_opt initializer_opt + { perm_string tmp3 = lex_strings.make($3); + $$ = pform_make_let_port(nullptr, tmp3, $4, $5); + delete[]$3; } - ; - -let_formal_type - : data_type_or_implicit - { $$ = $1; } - | K_untyped - { $$ = 0; } ; module_item_list