28
28
#define mts (x, y ) stack_expr(x).move_to_sub((irept &)stack_expr(y))
29
29
#define swapop (x, y ) stack_expr(x).operands().swap(stack_expr(y).operands())
30
30
#define addswap (x, y, z ) stack_expr(x).add(y).swap(stack_expr(z))
31
- #define push_scope (x, y ) PARSER.scopes.push_scope(x, y )
31
+ #define push_scope (name, separator, kind ) PARSER.scopes.push_scope(name, separator, kind )
32
32
#define pop_scope () PARSER.scopes.pop_scope();
33
33
34
34
int yyveriloglex ();
@@ -644,7 +644,7 @@ module_identifier_with_scope:
644
644
module_identifier
645
645
{
646
646
$$ = $1 ;
647
- push_scope (stack_expr($1 ).id(), ".");
647
+ push_scope (stack_expr($1 ).id(), ".", verilog_scopet::MODULE );
648
648
}
649
649
;
650
650
@@ -823,7 +823,7 @@ class_declaration:
823
823
{
824
824
init ($$, ID_verilog_class);
825
825
stack_expr ($$).set (ID_base_name, stack_expr ($2 ).id ());
826
- push_scope (stack_expr ($2 ).id (), " ::" );
826
+ push_scope (stack_expr ($2 ).id (), " ::" , verilog_scopet::CLASS );
827
827
}
828
828
class_item_brace
829
829
TOK_ENDCLASS
@@ -839,7 +839,7 @@ package_declaration:
839
839
lifetime_opt
840
840
package_identifier ' ;'
841
841
{
842
- push_scope (stack_expr ($5 ).id (), " ::" );
842
+ push_scope (stack_expr ($5 ).id (), " ::" , verilog_scopet::PACKAGE );
843
843
}
844
844
timeunits_declaration_opt
845
845
package_item_brace
@@ -1442,9 +1442,7 @@ net_declaration:
1442
1442
type_declaration:
1443
1443
TOK_TYPEDEF data_type new_identifier ' ;'
1444
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
-
1445
+ PARSER.scopes .add_name (stack_expr ($3 ).get (ID_identifier), " " , verilog_scopet::TYPEDEF);
1448
1446
init ($$, ID_decl);
1449
1447
stack_expr ($$).set (ID_class, ID_typedef);
1450
1448
addswap ($$, ID_type, $2 );
@@ -1535,7 +1533,7 @@ data_type:
1535
1533
1536
1534
// We attach a dummy id to distinguish two syntactically
1537
1535
// identical enum types.
1538
- auto id = PARSER.scopes .current_scope -> prefix + " enum-" + PARSER.get_next_id ();
1536
+ auto id = PARSER.scopes .current_scope (). prefix + " enum-" + PARSER.get_next_id ();
1539
1537
stack_expr ($$).set (ID_identifier, id);
1540
1538
}
1541
1539
| TOK_STRING
@@ -1569,7 +1567,7 @@ enum_name_declaration:
1569
1567
TOK_NON_TYPE_IDENTIFIER enum_name_value_opt
1570
1568
{
1571
1569
init ($$);
1572
- auto &scope = PARSER.scopes .add_name (stack_expr ($1 ).id (), " " );
1570
+ auto &scope = PARSER.scopes .add_name (stack_expr ($1 ).id (), " " , verilog_scopet::ENUM );
1573
1571
stack_expr ($$).set (ID_base_name, scope.base_name ());
1574
1572
stack_expr ($$).set (ID_identifier, scope.identifier ());
1575
1573
stack_expr ($$).add (ID_value).swap (stack_expr ($2 ));
@@ -2137,7 +2135,7 @@ function_declaration: TOK_FUNCTION lifetime_opt function_body_declaration
2137
2135
function_body_declaration:
2138
2136
function_data_type_or_implicit
2139
2137
function_identifier
2140
- { push_scope (stack_expr ($2 ).get (ID_identifier), " ." ); }
2138
+ { push_scope (stack_expr ($2 ).get (ID_identifier), " ." , verilog_scopet::FUNCTION ); }
2141
2139
' ;'
2142
2140
tf_item_declaration_brace statement
2143
2141
TOK_ENDFUNCTION
@@ -2152,7 +2150,7 @@ function_body_declaration:
2152
2150
}
2153
2151
| function_data_type_or_implicit
2154
2152
function_identifier
2155
- { push_scope (stack_expr ($2 ).get (ID_identifier), " ." ); }
2153
+ { push_scope (stack_expr ($2 ).get (ID_identifier), " ." , verilog_scopet::FUNCTION ); }
2156
2154
' (' tf_port_list_opt ' )' ' ;'
2157
2155
tf_item_declaration_brace statement
2158
2156
TOK_ENDFUNCTION
@@ -2193,7 +2191,7 @@ function_prototype: TOK_FUNCTION data_type_or_void function_identifier
2193
2191
2194
2192
task_declaration:
2195
2193
TOK_TASK task_identifier
2196
- { push_scope (stack_expr ($2 ).get (ID_identifier), " ." ); }
2194
+ { push_scope (stack_expr ($2 ).get (ID_identifier), " ." , verilog_scopet::TASK ); }
2197
2195
' ;'
2198
2196
tf_item_declaration_brace
2199
2197
statement_or_null TOK_ENDTASK
@@ -2205,7 +2203,7 @@ task_declaration:
2205
2203
pop_scope ();
2206
2204
}
2207
2205
| TOK_TASK task_identifier
2208
- { push_scope (stack_expr ($2 ).get (ID_identifier), " ." ); }
2206
+ { push_scope (stack_expr ($2 ).get (ID_identifier), " ." , verilog_scopet::TASK ); }
2209
2207
' (' tf_port_list_opt ' )' ' ;'
2210
2208
tf_item_declaration_brace
2211
2209
statement_or_null TOK_ENDTASK
@@ -3385,7 +3383,7 @@ seq_block:
3385
3383
TOK_END
3386
3384
{ init ($$, ID_block); swapop ($$, $2 ); }
3387
3385
| TOK_BEGIN TOK_COLON block_identifier
3388
- { push_scope (stack_expr ($3 ).id (), " ." ); }
3386
+ { push_scope (stack_expr ($3 ).id (), " ." , verilog_scopet::BLOCK ); }
3389
3387
block_item_declaration_or_statement_or_null_brace
3390
3388
TOK_END
3391
3389
{ init ($$, ID_block);
@@ -4222,10 +4220,19 @@ part_select_range:
4222
4220
4223
4221
primary: primary_literal
4224
4222
| hierarchical_identifier_select
4225
- | package_scope hierarchical_identifier_select
4226
- { init ($$, ID_verilog_package_scope);
4223
+ | package_scope
4224
+ {
4225
+ init ($$, ID_verilog_package_scope);
4226
+ // enter that scope
4227
+ PARSER.scopes .enter_package_scope (stack_expr ($1 ).id ());
4227
4228
mto ($$, $1 );
4228
- mto ($$, $2 ); }
4229
+ }
4230
+ hierarchical_identifier_select
4231
+ { $$ = $2 ;
4232
+ mto ($$, $3 );
4233
+ // exit the scope
4234
+ pop_scope ();
4235
+ }
4229
4236
| concatenation
4230
4237
| multiple_concatenation
4231
4238
| function_subroutine_call
@@ -4426,7 +4433,7 @@ type_identifier: TOK_TYPE_IDENTIFIER
4426
4433
init ($$, ID_typedef_type);
4427
4434
auto base_name = stack_expr ($1 ).id ();
4428
4435
stack_expr ($$).set (ID_base_name, base_name);
4429
- stack_expr ($$).set (ID_identifier, PARSER.scopes .current_scope -> prefix +id2string (base_name));
4436
+ stack_expr ($$).set (ID_identifier, PARSER.scopes .current_scope (). prefix +id2string (base_name));
4430
4437
}
4431
4438
;
4432
4439
0 commit comments