aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-01 16:53:11 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-01 18:26:34 +0900
commitcadd2245f7f10850e0b11e5b678b2049399a2d3e (patch)
treeb38681fb73b7089ebd4d05d61f491226ee46e931 /parse.y
parent7b9527ce74de11afc8e890db83f2a13a6ed5dc91 (diff)
downloadruby-cadd2245f7f10850e0b11e5b678b2049399a2d3e.tar.gz
Extracted `excessed_comma` to unify ripper and make the order stable
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y21
1 files changed, 14 insertions, 7 deletions
diff --git a/parse.y b/parse.y
index 0ac430456d..74cdd4a958 100644
--- a/parse.y
+++ b/parse.y
@@ -1143,7 +1143,7 @@ static int looking_at_eol_p(struct parser_params *p);
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
%type <id> p_kwrest p_kwnorest p_any_kwrest p_kw_label
-%type <id> f_no_kwarg f_any_kwrest args_forward
+%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma
%token END_OF_INPUT 0 "end-of-input"
%token <id> '.'
/* escaped chars, should be ignored otherwise */
@@ -3474,6 +3474,16 @@ opt_block_args_tail : ',' block_args_tail
}
;
+excessed_comma : ','
+ {
+ /* magic number for rest_id in iseq_set_arguments() */
+ /*%%%*/
+ $$ = NODE_SPECIAL_EXCESSIVE_COMMA;
+ /*% %*/
+ /*% ripper: excessed_comma! %*/
+ }
+ ;
+
block_param : f_arg ',' f_block_optarg ',' f_rest_arg opt_block_args_tail
{
$$ = new_args(p, $1, $3, $5, Qnone, $6, &@$);
@@ -3494,13 +3504,10 @@ block_param : f_arg ',' f_block_optarg ',' f_rest_arg opt_block_args_tail
{
$$ = new_args(p, $1, Qnone, $3, Qnone, $4, &@$);
}
- | f_arg ','
+ | f_arg excessed_comma
{
- /*%%%*/
- /* magic number for rest_id in iseq_set_arguments() */
- $$ = new_args(p, $1, Qnone, NODE_SPECIAL_EXCESSIVE_COMMA, Qnone, new_args_tail(p, Qnone, Qnone, Qnone, &@1), &@$);
- /*% %*/
- /*% ripper: new_args(p, $1, Qnone, excessed_comma!, Qnone, new_args_tail(p, Qnone, Qnone, Qnone, NULL), NULL) %*/
+ $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@2);
+ $$ = new_args(p, $1, Qnone, $2, Qnone, $$, &@$);
}
| f_arg ',' f_rest_arg ',' f_arg opt_block_args_tail
{