summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS-H-GAMELINKS <[email protected]>2024-06-09 10:49:04 +0900
committerNobuyoshi Nakada <[email protected]>2024-06-12 15:36:55 +0900
commit1fc07637240f7c55ffc1a033cff861d80445e47e (patch)
tree70d432a624b7f7646c41e019340bbee664d70086
parent01b13886dc96eb13688d448019a8699f9bdee5ac (diff)
Introduce `ident_or_const` inline rule
-rw-r--r--parse.y23
1 files changed, 11 insertions, 12 deletions
diff --git a/parse.y b/parse.y
index 486df5cd3c..d312797b98 100644
--- a/parse.y
+++ b/parse.y
@@ -2889,6 +2889,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
*/
%rule f_opt(value) <node_opt_arg>: f_arg_asgn f_eq value
@@ -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
;