Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ ruby28.y: unify kwrest and no-kwrest rules. #694

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 10 additions & 20 deletions lib/parser/ruby28.y
Expand Up @@ -1419,6 +1419,9 @@ rule
result = @builder.restarg(val[0])
}

f_any_kwrest: f_kwrest
| f_no_kwarg

block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
{
result = val[0].concat(val[2]).concat(val[3])
Expand All @@ -1427,11 +1430,7 @@ rule
{
result = val[0].concat(val[1])
}
| f_kwrest opt_f_block_arg
{
result = val[0].concat(val[1])
}
| f_no_kwarg opt_f_block_arg
| f_any_kwrest opt_f_block_arg
{
result = val[0].concat(val[1])
}
Expand Down Expand Up @@ -2030,7 +2029,7 @@ opt_block_args_tail:

p_arg: p_expr

p_kwargs: p_kwarg tCOMMA p_kwrest
p_kwargs: p_kwarg tCOMMA p_any_kwrest
{
result = [ *val[0], *val[2] ]
}
Expand All @@ -2042,18 +2041,10 @@ opt_block_args_tail:
{
result = val[0]
}
| p_kwrest
| p_any_kwrest
{
result = val[0]
}
| p_kwarg tCOMMA p_kwnorest
{
result = [ *val[0], *val[2] ]
}
| p_kwnorest
{
result = [ *val[0], *val[2] ]
}

p_kwarg: p_kw
{
Expand Down Expand Up @@ -2097,6 +2088,9 @@ opt_block_args_tail:
result = [ @builder.match_nil_pattern(val[0], val[1]) ]
}

p_any_kwrest: p_kwrest
| p_kwnorest

p_value: p_primitive
| p_primitive tDOT2 p_primitive
{
Expand Down Expand Up @@ -2597,11 +2591,7 @@ keyword_variable: kNIL
{
result = val[0].concat(val[1])
}
| f_kwrest opt_f_block_arg
{
result = val[0].concat(val[1])
}
| f_no_kwarg opt_f_block_arg
| f_any_kwrest opt_f_block_arg
{
result = val[0].concat(val[1])
}
Expand Down