Skip to content

Commit cabf866

Browse files
authored
Merge pull request #293 from diffblue/verilog-select-rule
Verilog: grammar for hierarchical_identifier select
2 parents d74cc4a + 88cc25e commit cabf866

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/verilog/parser.y

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,9 +2633,7 @@ part_select_range:
26332633
// A.8.4 Primaries
26342634

26352635
primary: primary_literal
2636-
| indexed_variable_lvalue
2637-
| indexed_variable_lvalue '[' part_select_range ']'
2638-
{ extractbits($$, $1, $3); }
2636+
| hierarchical_identifier_select
26392637
| concatenation
26402638
| replication
26412639
| function_subroutine_call
@@ -2649,6 +2647,20 @@ primary_literal:
26492647
| time_literal
26502648
;
26512649

2650+
// This is equivalent to two System Verilog 1800-2017 productions
2651+
// hierarchical_identifier select.
2652+
hierarchical_identifier_select:
2653+
hierarchical_identifier_bit_select_brace
2654+
| hierarchical_identifier_bit_select_brace '[' part_select_range ']'
2655+
{ extractbits($$, $1, $3); }
2656+
;
2657+
2658+
hierarchical_identifier_bit_select_brace:
2659+
hierarchical_variable_identifier
2660+
| hierarchical_identifier_bit_select_brace bit_select
2661+
{ extractbit($$, $1, $2); }
2662+
;
2663+
26522664
time_literal: TOK_TIME_LITERAL
26532665
{ init($$, ID_constant);
26542666
addswap($$, ID_value, $1);
@@ -2661,9 +2673,7 @@ time_literal: TOK_TIME_LITERAL
26612673
net_lvalue: variable_lvalue;
26622674

26632675
variable_lvalue:
2664-
indexed_variable_lvalue
2665-
| indexed_variable_lvalue '[' part_select_range ']'
2666-
{ extractbits($$, $1, $3); }
2676+
hierarchical_identifier_select
26672677
| concatenation
26682678
/* more generous than the rule below to avoid conflict */
26692679
/*
@@ -2679,12 +2689,6 @@ variable_concatenation_lvalue_brace:
26792689
{ $$=$1; mto($$, $3); }
26802690
;
26812691

2682-
indexed_variable_lvalue:
2683-
hierarchical_variable_identifier
2684-
| indexed_variable_lvalue bit_select
2685-
{ extractbit($$, $1, $2); }
2686-
;
2687-
26882692
const_expression: expression;
26892693

26902694
mintypmax_expression:

0 commit comments

Comments
 (0)