Introduce ident_or_const inline rule

This commit is contained in:
S-H-GAMELINKS 2024-06-09 10:49:04 +09:00 committed by Nobuyoshi Nakada
parent 01b13886dc
commit 1fc0763724

23
parse.y
View file

@ -2888,6 +2888,13 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
%token tLAST_TOKEN %token tLAST_TOKEN
/*
* inlining rules
*/
%rule %inline ident_or_const: tIDENTIFIER
| tCONSTANT
;
/* /*
* parameterizing rules * parameterizing rules
*/ */
@ -3232,12 +3239,7 @@ command_asgn : lhs '=' lex_ctxt command_rhs
/*% ripper: opassign!(aref_field!($:1, $:3), $:5, $:7) %*/ /*% ripper: opassign!(aref_field!($:1, $:3), $:5, $:7) %*/
} }
| primary_value call_op tIDENTIFIER tOP_ASGN lex_ctxt command_rhs | primary_value call_op ident_or_const tOP_ASGN lex_ctxt command_rhs
{
$$ = new_attr_op_assign(p, $1, $2, $3, $4, $6, &@$);
/*% ripper: opassign!(field!($:1, $:2, $:3), $:4, $:6) %*/
}
| primary_value call_op tCONSTANT tOP_ASGN lex_ctxt command_rhs
{ {
$$ = new_attr_op_assign(p, $1, $2, $3, $4, $6, &@$); $$ = new_attr_op_assign(p, $1, $2, $3, $4, $6, &@$);
/*% ripper: opassign!(field!($:1, $:2, $:3), $:4, $:6) %*/ /*% ripper: opassign!(field!($:1, $:2, $:3), $:4, $:6) %*/
@ -3744,8 +3746,7 @@ cpath : tCOLON3 cname
} }
; ;
fname : tIDENTIFIER fname : ident_or_const
| tCONSTANT
| tFID | tFID
| op | op
{ {
@ -6267,8 +6268,7 @@ nonlocal_var : tIVAR
| tCVAR | tCVAR
; ;
user_variable : tIDENTIFIER user_variable : ident_or_const
| tCONSTANT
| nonlocal_var | nonlocal_var
; ;
@ -6810,8 +6810,7 @@ assoc : arg_value tASSOC arg_value
} }
; ;
operation : tIDENTIFIER operation : ident_or_const
| tCONSTANT
| tFID | tFID
; ;