From 1fc07637240f7c55ffc1a033cff861d80445e47e Mon Sep 17 00:00:00 2001 From: S-H-GAMELINKS Date: Sun, 9 Jun 2024 10:49:04 +0900 Subject: [PATCH] Introduce `ident_or_const` inline rule --- parse.y | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/parse.y b/parse.y index 486df5cd3c..d312797b98 100644 --- a/parse.y +++ b/parse.y @@ -2888,6 +2888,13 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary) %token tLAST_TOKEN +/* + * inlining rules + */ +%rule %inline ident_or_const: tIDENTIFIER + | tCONSTANT + ; + /* * parameterizing rules */ @@ -3232,12 +3239,7 @@ command_asgn : lhs '=' lex_ctxt command_rhs /*% ripper: opassign!(aref_field!($:1, $:3), $:5, $:7) %*/ } - | primary_value call_op tIDENTIFIER 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 + | 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) %*/ @@ -3744,8 +3746,7 @@ cpath : tCOLON3 cname } ; -fname : tIDENTIFIER - | tCONSTANT +fname : ident_or_const | tFID | op { @@ -6267,8 +6268,7 @@ nonlocal_var : tIVAR | tCVAR ; -user_variable : tIDENTIFIER - | tCONSTANT +user_variable : ident_or_const | nonlocal_var ; @@ -6810,8 +6810,7 @@ assoc : arg_value tASSOC arg_value } ; -operation : tIDENTIFIER - | tCONSTANT +operation : ident_or_const | tFID ;