parser: Consolidate named expression parsing
There are a few different places in the parser that all parse named expressions in the same way. Consolidate them into a single rule. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
e7f66fe7ac
commit
4036c77416
43
parse.y
43
parse.y
|
|
@ -675,7 +675,7 @@ Module::port_t *module_declare_port(const YYLTYPE&loc, char *id,
|
||||||
%type <tf_ports> tf_port_declaration tf_port_item tf_port_item_list
|
%type <tf_ports> tf_port_declaration tf_port_item tf_port_item_list
|
||||||
%type <tf_ports> tf_port_list tf_port_list_opt tf_port_list_parens_opt
|
%type <tf_ports> tf_port_list tf_port_list_opt tf_port_list_parens_opt
|
||||||
|
|
||||||
%type <named_pexpr> modport_simple_port port_name parameter_value_byname
|
%type <named_pexpr> named_expression named_expression_opt port_name
|
||||||
%type <named_pexprs> port_name_list parameter_value_byname_list
|
%type <named_pexprs> port_name_list parameter_value_byname_list
|
||||||
%type <exprs> port_conn_expression_list_with_nuls
|
%type <exprs> port_conn_expression_list_with_nuls
|
||||||
|
|
||||||
|
|
@ -1975,7 +1975,7 @@ modport_item
|
||||||
modport_ports_list
|
modport_ports_list
|
||||||
: modport_ports_declaration
|
: modport_ports_declaration
|
||||||
| modport_ports_list ',' modport_ports_declaration
|
| modport_ports_list ',' modport_ports_declaration
|
||||||
| modport_ports_list ',' modport_simple_port
|
| modport_ports_list ',' named_expression
|
||||||
{ if (last_modport_port.type == MP_SIMPLE) {
|
{ if (last_modport_port.type == MP_SIMPLE) {
|
||||||
pform_add_modport_port(@3, last_modport_port.direction,
|
pform_add_modport_port(@3, last_modport_port.direction,
|
||||||
$3->name, $3->parm);
|
$3->name, $3->parm);
|
||||||
|
|
@ -2009,7 +2009,7 @@ modport_ports_declaration
|
||||||
delete[] $3;
|
delete[] $3;
|
||||||
delete $1;
|
delete $1;
|
||||||
}
|
}
|
||||||
| attribute_list_opt port_direction modport_simple_port
|
| attribute_list_opt port_direction named_expression
|
||||||
{ last_modport_port.type = MP_SIMPLE;
|
{ last_modport_port.type = MP_SIMPLE;
|
||||||
last_modport_port.direction = $2;
|
last_modport_port.direction = $2;
|
||||||
pform_add_modport_port(@3, $2, $3->name, $3->parm);
|
pform_add_modport_port(@3, $2, $3->name, $3->parm);
|
||||||
|
|
@ -2038,16 +2038,6 @@ modport_ports_declaration
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
modport_simple_port
|
|
||||||
: '.' IDENTIFIER '(' expression ')'
|
|
||||||
{ named_pexpr_t*tmp = new named_pexpr_t;
|
|
||||||
tmp->name = lex_strings.make($2);
|
|
||||||
tmp->parm = $4;
|
|
||||||
delete[]$2;
|
|
||||||
$$ = tmp;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
modport_tf_port
|
modport_tf_port
|
||||||
: K_task IDENTIFIER tf_port_list_parens_opt
|
: K_task IDENTIFIER tf_port_list_parens_opt
|
||||||
| K_function data_type_or_implicit_or_void IDENTIFIER tf_port_list_parens_opt
|
| K_function data_type_or_implicit_or_void IDENTIFIER tf_port_list_parens_opt
|
||||||
|
|
@ -5550,7 +5540,7 @@ parameter_value_opt
|
||||||
{ $$ = 0; }
|
{ $$ = 0; }
|
||||||
;
|
;
|
||||||
|
|
||||||
parameter_value_byname
|
named_expression
|
||||||
: '.' IDENTIFIER '(' expression ')'
|
: '.' IDENTIFIER '(' expression ')'
|
||||||
{ named_pexpr_t*tmp = new named_pexpr_t;
|
{ named_pexpr_t*tmp = new named_pexpr_t;
|
||||||
tmp->name = lex_strings.make($2);
|
tmp->name = lex_strings.make($2);
|
||||||
|
|
@ -5558,6 +5548,9 @@ parameter_value_byname
|
||||||
delete[]$2;
|
delete[]$2;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
named_expression_opt
|
||||||
|
: named_expression
|
||||||
| '.' IDENTIFIER '(' ')'
|
| '.' IDENTIFIER '(' ')'
|
||||||
{ named_pexpr_t*tmp = new named_pexpr_t;
|
{ named_pexpr_t*tmp = new named_pexpr_t;
|
||||||
tmp->name = lex_strings.make($2);
|
tmp->name = lex_strings.make($2);
|
||||||
|
|
@ -5568,13 +5561,13 @@ parameter_value_byname
|
||||||
;
|
;
|
||||||
|
|
||||||
parameter_value_byname_list
|
parameter_value_byname_list
|
||||||
: parameter_value_byname
|
: named_expression_opt
|
||||||
{ std::list<named_pexpr_t>*tmp = new std::list<named_pexpr_t>;
|
{ std::list<named_pexpr_t>*tmp = new std::list<named_pexpr_t>;
|
||||||
tmp->push_back(*$1);
|
tmp->push_back(*$1);
|
||||||
delete $1;
|
delete $1;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
| parameter_value_byname_list ',' parameter_value_byname
|
| parameter_value_byname_list ',' named_expression_opt
|
||||||
{ std::list<named_pexpr_t>*tmp = $1;
|
{ std::list<named_pexpr_t>*tmp = $1;
|
||||||
tmp->push_back(*$3);
|
tmp->push_back(*$3);
|
||||||
delete $3;
|
delete $3;
|
||||||
|
|
@ -5643,13 +5636,9 @@ port_opt
|
||||||
looking for the ports of a module declaration. */
|
looking for the ports of a module declaration. */
|
||||||
|
|
||||||
port_name
|
port_name
|
||||||
: attribute_list_opt '.' IDENTIFIER '(' expression ')'
|
: attribute_list_opt named_expression_opt
|
||||||
{ named_pexpr_t*tmp = new named_pexpr_t;
|
{ delete $1;
|
||||||
tmp->name = lex_strings.make($3);
|
$$ = $2;
|
||||||
tmp->parm = $5;
|
|
||||||
delete[]$3;
|
|
||||||
delete $1;
|
|
||||||
$$ = tmp;
|
|
||||||
}
|
}
|
||||||
| attribute_list_opt '.' IDENTIFIER '(' error ')'
|
| attribute_list_opt '.' IDENTIFIER '(' error ')'
|
||||||
{ yyerror(@3, "error: Invalid port connection expression.");
|
{ yyerror(@3, "error: Invalid port connection expression.");
|
||||||
|
|
@ -5660,14 +5649,6 @@ port_name
|
||||||
delete $1;
|
delete $1;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
| attribute_list_opt '.' IDENTIFIER '(' ')'
|
|
||||||
{ named_pexpr_t*tmp = new named_pexpr_t;
|
|
||||||
tmp->name = lex_strings.make($3);
|
|
||||||
tmp->parm = 0;
|
|
||||||
delete[]$3;
|
|
||||||
delete $1;
|
|
||||||
$$ = tmp;
|
|
||||||
}
|
|
||||||
| attribute_list_opt '.' IDENTIFIER
|
| attribute_list_opt '.' IDENTIFIER
|
||||||
{ pform_requires_sv(@3, "Implicit named port connections");
|
{ pform_requires_sv(@3, "Implicit named port connections");
|
||||||
named_pexpr_t*tmp = new named_pexpr_t;
|
named_pexpr_t*tmp = new named_pexpr_t;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue