@@ -1440,16 +1440,18 @@ net_declaration:
1440
1440
// Note that the identifier that is defined using the typedef may be
1441
1441
// an existing type or non-type identifier.
1442
1442
type_declaration:
1443
- TOK_TYPEDEF data_type new_identifier ' ;'
1444
- { // add to the scope as a type name
1445
- auto &name = PARSER.scopes .add_name (stack_expr ($3 ).get (ID_identifier), " " );
1446
- name.is_type = true ;
1447
-
1448
- init ($$, ID_decl);
1443
+ TOK_TYPEDEF
1444
+ { init ($$, ID_decl);
1449
1445
stack_expr ($$).set (ID_class, ID_typedef);
1450
- addswap ($$, ID_type, $2 );
1451
- stack_expr ($3 ).id (ID_declarator);
1452
- mto ($$, $3 );
1446
+ }
1447
+ data_type any_identifier ' ;'
1448
+ { $$ = $2 ;
1449
+ // add to the scope as a type name
1450
+ auto &name = PARSER.scopes .add_name (stack_expr ($4 ).get (ID_identifier), " " );
1451
+ name.is_type = true ;
1452
+ addswap ($$, ID_type, $3 );
1453
+ stack_expr ($4 ).id (ID_declarator);
1454
+ mto ($$, $4 );
1453
1455
}
1454
1456
;
1455
1457
@@ -2679,7 +2681,7 @@ expression_or_dist:
2679
2681
// A.2.11 Covergroup declarations
2680
2682
2681
2683
covergroup_declaration:
2682
- TOK_COVERGROUP new_identifier tf_port_list_paren_opt coverage_event_opt ' ;'
2684
+ TOK_COVERGROUP any_identifier tf_port_list_paren_opt coverage_event_opt ' ;'
2683
2685
coverage_spec_or_option_brace TOK_ENDGROUP
2684
2686
{ init ($$, ID_verilog_covergroup); }
2685
2687
;
@@ -3194,13 +3196,13 @@ udp_initial_statement:
3194
3196
TOK_INITIAL output_port_identifier ' =' init_val ' ;'
3195
3197
;
3196
3198
3197
- output_port_identifier: new_identifier
3199
+ output_port_identifier: any_identifier
3198
3200
;
3199
3201
3200
3202
init_val:
3201
3203
// Really 1'b0 | 1'b1 | 1'bx | 1'bX | 1'B0 | 1'B1 | 1'Bx | 1'BX | 1 | 0
3202
3204
TOK_NUMBER
3203
- | new_identifier
3205
+ | any_identifier
3204
3206
;
3205
3207
3206
3208
sequential_entry_brace:
@@ -3233,7 +3235,7 @@ edge_input_list: level_symbol_brace edge_indicator level_symbol_brace ;
3233
3235
output_symbol:
3234
3236
// Really 0 | 1 | x | X
3235
3237
TOK_NUMBER
3236
- | new_identifier
3238
+ | any_identifier
3237
3239
;
3238
3240
3239
3241
level_symbol_brace:
@@ -3244,13 +3246,13 @@ level_symbol_brace:
3244
3246
level_symbol:
3245
3247
// Really 0 | 1 | x | X | ? | b | B
3246
3248
TOK_NUMBER
3247
- | new_identifier
3249
+ | any_identifier
3248
3250
;
3249
3251
3250
3252
edge_symbol:
3251
3253
// Really r | R | f | F | p | P | n | N | *
3252
3254
TOK_NUMBER
3253
- | new_identifier
3255
+ | any_identifier
3254
3256
;
3255
3257
3256
3258
// System Verilog standard 1800-2017
@@ -4362,9 +4364,10 @@ attr_name: identifier
4362
4364
// System Verilog standard 1800-2017
4363
4365
// A.9.3 Identifiers
4364
4366
4365
- // An extension of the System Verilog grammar to allow defining new types
4366
- // using an existing type or non-type identifier.
4367
- new_identifier:
4367
+ // An extension of the System Verilog grammar to allow defining new identifiers
4368
+ // even if they are already used for a different kind of identifier
4369
+ // in a higher scope.
4370
+ any_identifier:
4368
4371
type_identifier
4369
4372
| non_type_identifier
4370
4373
;
0 commit comments