diff --git a/parse.y b/parse.y index 76947fd03..c22e299e9 100644 --- a/parse.y +++ b/parse.y @@ -597,6 +597,7 @@ static void current_function_set_statement(const YYLTYPE&loc, vector %type modport_simple_port port_name parameter_value_byname %type port_name_list parameter_value_byname_list +%type port_conn_expression_list_with_nuls %type attribute %type attribute_list attribute_instance_list attribute_list_opt @@ -3922,7 +3923,7 @@ function_item /* A gate_instance is a module instantiation or a built in part type. In any case, the gate has a set of connections to ports. */ gate_instance - : IDENTIFIER '(' expression_list_with_nuls ')' + : IDENTIFIER '(' port_conn_expression_list_with_nuls ')' { lgate*tmp = new lgate; tmp->name = $1; tmp->parms = $3; @@ -3932,7 +3933,7 @@ gate_instance $$ = tmp; } - | IDENTIFIER dimensions '(' expression_list_with_nuls ')' + | IDENTIFIER dimensions '(' port_conn_expression_list_with_nuls ')' { lgate*tmp = new lgate; list*rng = $2; tmp->name = $1; @@ -3947,7 +3948,7 @@ gate_instance $$ = tmp; } - | '(' expression_list_with_nuls ')' + | '(' port_conn_expression_list_with_nuls ')' { lgate*tmp = new lgate; tmp->name = ""; tmp->parms = $2; @@ -5471,34 +5472,38 @@ port_opt looking for the ports of a module declaration. */ port_name - : '.' IDENTIFIER '(' expression ')' + : attribute_list_opt '.' IDENTIFIER '(' expression ')' { named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); - tmp->parm = $4; - delete[]$2; + tmp->name = lex_strings.make($3); + tmp->parm = $5; + delete[]$3; + delete $1; $$ = tmp; } - | '.' IDENTIFIER '(' error ')' + | attribute_list_opt '.' IDENTIFIER '(' error ')' { yyerror(@3, "error: invalid port connection expression."); named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); + tmp->name = lex_strings.make($3); tmp->parm = 0; - delete[]$2; + delete[]$3; + delete $1; $$ = tmp; } - | '.' IDENTIFIER '(' ')' + | attribute_list_opt '.' IDENTIFIER '(' ')' { named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); + tmp->name = lex_strings.make($3); tmp->parm = 0; - delete[]$2; + delete[]$3; + delete $1; $$ = tmp; } - | '.' IDENTIFIER + | attribute_list_opt '.' IDENTIFIER { named_pexpr_t*tmp = new named_pexpr_t; - tmp->name = lex_strings.make($2); - tmp->parm = new PEIdent(lex_strings.make($2), true); + tmp->name = lex_strings.make($3); + tmp->parm = new PEIdent(lex_strings.make($3), true); FILE_NAME(tmp->parm, @1); - delete[]$2; + delete[]$3; + delete $1; $$ = tmp; } | K_DOTSTAR @@ -5524,6 +5529,31 @@ port_name_list } ; +port_conn_expression_list_with_nuls + : port_conn_expression_list_with_nuls ',' attribute_list_opt expression + { list*tmp = $1; + tmp->push_back($4); + delete $3; + $$ = tmp; + } + | attribute_list_opt expression + { list*tmp = new list; + tmp->push_back($2); + delete $1; + $$ = tmp; + } + | + { list*tmp = new list; + tmp->push_back(0); + $$ = tmp; + } + | port_conn_expression_list_with_nuls ',' + { list*tmp = $1; + tmp->push_back(0); + $$ = tmp; + } + ; + /* A port reference is an internal (to the module) name of the port, possibly with a part of bit select to attach it to specific bits