ruby-changes:61445
From: Nobuyoshi <ko1@a...>
Date: Mon, 1 Jun 2020 18:31:18 +0900 (JST)
Subject: [ruby-changes:61445] cadd2245f7 (master): Extracted `excessed_comma` to unify ripper and make the order stable
https://git.ruby-lang.org/ruby.git/commit/?id=cadd2245f7 From cadd2245f7f10850e0b11e5b678b2049399a2d3e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 1 Jun 2020 16:53:11 +0900 Subject: Extracted `excessed_comma` to unify ripper and make the order stable diff --git a/parse.y b/parse.y index 0ac4304..74cdd4a 100644 --- a/parse.y +++ b/parse.y @@ -1143,7 +1143,7 @@ static int looking_at_eol_p(struct parser_params *p); https://github.com/ruby/ruby/blob/trunk/parse.y#L1143 %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 https://github.com/ruby/ruby/blob/trunk/parse.y#L3474 } ; +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 https://github.com/ruby/ruby/blob/trunk/parse.y#L3504 { $$ = 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 { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/