@@ -911,13 +911,6 @@ part_select:
911911 { init($$ , ID_part_select); mto($$ , $2 ); mto($$ , $4 ); }
912912 ;
913913
914- indexed_part_select :
915- ' [' const_expression TOK_PLUSCOLON const_expression ' ]'
916- { init($$ , ID_indexed_part_select_plus); mto($$ , $2 ); mto($$ , $4 ); }
917- | ' [' const_expression TOK_MINUSCOLON const_expression ' ]'
918- { init($$ , ID_indexed_part_select_minus); mto($$ , $2 ); mto($$ , $4 ); }
919- ;
920-
921914// System Verilog standard 1800-2017
922915// A.2.1.3 Type declarations
923916
@@ -2616,15 +2609,30 @@ inc_or_dec_expression:
26162609 { init($$ , ID_postdecrement); mto($$ , $1 ); }
26172610 ;
26182611
2612+ constant_range :
2613+ const_expression TOK_COLON const_expression
2614+ { init($$ , ID_part_select); mto($$ , $1 ); mto($$ , $3 ); }
2615+ ;
2616+
2617+ indexed_range :
2618+ expression TOK_PLUSCOLON constant_expression
2619+ { init($$ , ID_indexed_part_select_plus); mto($$ , $1 ); mto($$ , $3 ); }
2620+ | expression TOK_MINUSCOLON constant_expression
2621+ { init($$ , ID_indexed_part_select_minus); mto($$ , $1 ); mto($$ , $3 ); }
2622+ ;
2623+
2624+ part_select_range :
2625+ constant_range
2626+ | indexed_range
2627+ ;
2628+
26192629// System Verilog standard 1800-2017
26202630// A.8.4 Primaries
26212631
26222632primary : primary_literal
26232633 | indexed_variable_lvalue
2624- | indexed_variable_lvalue part_select
2625- { extractbits($$ , $1 , $2 ); }
2626- | indexed_variable_lvalue indexed_part_select
2627- { extractbits($$ , $1 , $2 ); }
2634+ | indexed_variable_lvalue ' [' part_select_range ' ]'
2635+ { extractbits($$ , $1 , $3 ); }
26282636 | concatenation
26292637 | replication
26302638 | function_subroutine_call
@@ -2651,10 +2659,8 @@ net_lvalue: variable_lvalue;
26512659
26522660variable_lvalue :
26532661 indexed_variable_lvalue
2654- | indexed_variable_lvalue part_select
2655- { extractbits($$ , $1 , $2 ); }
2656- | indexed_variable_lvalue indexed_part_select
2657- { extractbits($$ , $1 , $2 ); }
2662+ | indexed_variable_lvalue ' [' part_select_range ' ]'
2663+ { extractbits($$ , $1 , $3 ); }
26582664 | concatenation
26592665 /* more generous than the rule below to avoid conflict */
26602666 /*
0 commit comments