ruby-changes:60367
From: Nobuyoshi <ko1@a...>
Date: Wed, 11 Mar 2020 18:18:10 +0900 (JST)
Subject: [ruby-changes:60367] 276859e03e (master): parse.y: unified kwrest and no-kwrest
https://git.ruby-lang.org/ruby.git/commit/?id=276859e03e From 276859e03e8e1adfdd445ce1e1aba2794ee0debe Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 10 Mar 2020 23:19:50 +0900 Subject: parse.y: unified kwrest and no-kwrest diff --git a/parse.y b/parse.y index a7c6860..5a0ee21 100644 --- a/parse.y +++ b/parse.y @@ -1107,8 +1107,8 @@ static int looking_at_eol_p(struct parser_params *p); https://github.com/ruby/ruby/blob/trunk/parse.y#L1107 %type <id> keyword_variable user_variable sym operation operation2 operation3 %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_kw_label -%type <id> f_no_kwarg args_forward +%type <id> p_kwrest p_kwnorest p_any_kwrest p_kw_label +%type <id> f_no_kwarg f_any_kwrest args_forward %token END_OF_INPUT 0 "end-of-input" %token <id> '.' /* escaped chars, should be ignored otherwise */ @@ -3344,6 +3344,10 @@ f_rest_marg : tSTAR f_norm_arg https://github.com/ruby/ruby/blob/trunk/parse.y#L3344 } ; +f_any_kwrest : f_kwrest + | f_no_kwarg {$$ = ID2VAL(idNil);} + ; + block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg { $$ = new_args_tail(p, $1, $3, $4, &@3); @@ -3352,14 +3356,10 @@ block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg https://github.com/ruby/ruby/blob/trunk/parse.y#L3356 { $$ = new_args_tail(p, $1, Qnone, $2, &@1); } - | f_kwrest opt_f_block_arg + | f_any_kwrest opt_f_block_arg { $$ = new_args_tail(p, Qnone, $1, $2, &@1); } - | f_no_kwarg opt_f_block_arg - { - $$ = new_args_tail(p, Qnone, ID2VAL(idNil), $2, &@1); - } | f_block_arg { $$ = new_args_tail(p, Qnone, Qnone, $1, &@1); @@ -4076,7 +4076,7 @@ p_arg : p_expr https://github.com/ruby/ruby/blob/trunk/parse.y#L4076 } ; -p_kwargs : p_kwarg ',' p_kwrest +p_kwargs : p_kwarg ',' p_any_kwrest { $$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), $3, &@$); } @@ -4088,18 +4088,10 @@ p_kwargs : p_kwarg ',' p_kwrest https://github.com/ruby/ruby/blob/trunk/parse.y#L4088 { $$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), 0, &@$); } - | p_kwrest + | p_any_kwrest { $$ = new_hash_pattern_tail(p, new_hash(p, Qnone, &@$), $1, &@$); } - | p_kwarg ',' p_kwnorest - { - $$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), ID2VAL(idNil), &@$); - } - | p_kwnorest - { - $$ = new_hash_pattern_tail(p, new_hash(p, Qnone, &@$), ID2VAL(idNil), &@$); - } ; p_kwarg : p_kw @@ -4175,6 +4167,10 @@ p_kwnorest : kwrest_mark keyword_nil https://github.com/ruby/ruby/blob/trunk/parse.y#L4167 } ; +p_any_kwrest : p_kwrest + | p_kwnorest {$$ = ID2VAL(idNil);} + ; + p_value : p_primitive | p_primitive tDOT2 p_primitive { @@ -4885,14 +4881,10 @@ args_tail : f_kwarg ',' f_kwrest opt_f_block_arg https://github.com/ruby/ruby/blob/trunk/parse.y#L4881 { $$ = new_args_tail(p, $1, Qnone, $2, &@1); } - | f_kwrest opt_f_block_arg + | f_any_kwrest opt_f_block_arg { $$ = new_args_tail(p, Qnone, $1, $2, &@1); } - | f_no_kwarg opt_f_block_arg - { - $$ = new_args_tail(p, Qnone, ID2VAL(idNil), $2, &@1); - } | f_block_arg { $$ = new_args_tail(p, Qnone, Qnone, $1, &@1); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/