parse.y: unified kwrest and no-kwrest

This commit is contained in:
Nobuyoshi Nakada 2020-03-10 23:19:50 +09:00
Родитель da4b97a0e3
Коммит 276859e03e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BC7D6DF58D8DF60
1 изменённых файлов: 14 добавлений и 22 удалений

36
parse.y
Просмотреть файл

@ -1107,8 +1107,8 @@ static int looking_at_eol_p(struct parser_params *p);
%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
}
;
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
{
$$ = 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
}
;
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
{
$$ = 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
}
;
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
{
$$ = 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);