Add common parser rule for (scoped) type identifier
There are multiple places in the grammar where either a type identifier or scoped type identifier is accepted. Factor this into a common parser rule. This removes some duplicated code. But it will also be required to avoid reduce-reduce conflicts for future grammar extensions, e.g. to support type parameters. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
bc0fc4ab89
commit
4bebcad6fd
39
parse.y
39
parse.y
|
|
@ -644,6 +644,7 @@ static void current_function_set_statement(const YYLTYPE&loc, std::vector<Statem
|
||||||
%type <data_type> data_type data_type_or_implicit data_type_or_implicit_or_void
|
%type <data_type> data_type data_type_or_implicit data_type_or_implicit_or_void
|
||||||
%type <data_type> simple_type_or_string let_formal_type
|
%type <data_type> simple_type_or_string let_formal_type
|
||||||
%type <data_type> packed_array_data_type
|
%type <data_type> packed_array_data_type
|
||||||
|
%type <data_type> ps_type_identifier
|
||||||
%type <class_type> class_identifier
|
%type <class_type> class_identifier
|
||||||
%type <struct_member> struct_union_member
|
%type <struct_member> struct_union_member
|
||||||
%type <struct_members> struct_union_member_list
|
%type <struct_members> struct_union_member_list
|
||||||
|
|
@ -1178,17 +1179,8 @@ data_declaration /* IEEE1800-2005: A.2.1.3 */
|
||||||
| attribute_list_opt package_import_declaration
|
| attribute_list_opt package_import_declaration
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Data types that can have packed dimensions directly attached to it */
|
ps_type_identifier /* IEEE1800-2017: A.9.3 */
|
||||||
packed_array_data_type /* IEEE1800-2005: A.2.2.1 */
|
: TYPE_IDENTIFIER
|
||||||
: enum_data_type
|
|
||||||
{ $$ = $1; }
|
|
||||||
| struct_data_type
|
|
||||||
{ if (!$1->packed_flag) {
|
|
||||||
yyerror(@1, "sorry: Unpacked structs not supported.");
|
|
||||||
}
|
|
||||||
$$ = $1;
|
|
||||||
}
|
|
||||||
| TYPE_IDENTIFIER
|
|
||||||
{ pform_set_type_referenced(@1, $1.text);
|
{ pform_set_type_referenced(@1, $1.text);
|
||||||
delete[]$1.text;
|
delete[]$1.text;
|
||||||
$$ = $1.type;
|
$$ = $1.type;
|
||||||
|
|
@ -1200,6 +1192,18 @@ packed_array_data_type /* IEEE1800-2005: A.2.2.1 */
|
||||||
$$ = $4.type;
|
$$ = $4.type;
|
||||||
delete[]$4.text;
|
delete[]$4.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Data types that can have packed dimensions directly attached to it */
|
||||||
|
packed_array_data_type /* IEEE1800-2005: A.2.2.1 */
|
||||||
|
: enum_data_type
|
||||||
|
{ $$ = $1; }
|
||||||
|
| struct_data_type
|
||||||
|
{ if (!$1->packed_flag) {
|
||||||
|
yyerror(@1, "sorry: Unpacked structs not supported.");
|
||||||
|
}
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
| ps_type_identifier
|
||||||
;
|
;
|
||||||
|
|
||||||
data_type /* IEEE1800-2005: A.2.2.1 */
|
data_type /* IEEE1800-2005: A.2.2.1 */
|
||||||
|
|
@ -2243,23 +2247,12 @@ simple_type_or_string /* IEEE1800-2005: A.2.2.1 */
|
||||||
tmp->reg_flag = !gn_system_verilog();
|
tmp->reg_flag = !gn_system_verilog();
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
| TYPE_IDENTIFIER
|
|
||||||
{ pform_set_type_referenced(@1, $1.text);
|
|
||||||
$$ = $1.type;
|
|
||||||
delete[]$1.text;
|
|
||||||
}
|
|
||||||
| PACKAGE_IDENTIFIER K_SCOPE_RES
|
|
||||||
{ lex_in_package_scope($1); }
|
|
||||||
TYPE_IDENTIFIER
|
|
||||||
{ lex_in_package_scope(0);
|
|
||||||
$$ = $4.type;
|
|
||||||
delete[]$4.text;
|
|
||||||
}
|
|
||||||
| K_string
|
| K_string
|
||||||
{ string_type_t*tmp = new string_type_t;
|
{ string_type_t*tmp = new string_type_t;
|
||||||
FILE_NAME(tmp, @1);
|
FILE_NAME(tmp, @1);
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
| ps_type_identifier
|
||||||
;
|
;
|
||||||
|
|
||||||
statement /* IEEE1800-2005: A.6.4 */
|
statement /* IEEE1800-2005: A.6.4 */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue