Skip to content

Commit

Permalink
Introduce backref_with_rhs parameterizing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
S-H-GAMELINKS authored and nobu committed Jan 2, 2025
1 parent 03b37fb commit 1686c6b
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -2911,6 +2911,15 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
/*
* parameterizing rules
*/
%rule backref_with_rhs(value) <node>
: backref tOP_ASGN lex_ctxt value
{
VALUE MAYBE_UNUSED(e) = rb_backref_error(p, $1);
$$ = NEW_ERROR(&@$);
/*% ripper[error]: assign_error!(?e, opassign!(var_field!($:1), $:2, $:4)) %*/
}
;

%rule f_opt(value) <node_opt_arg>
: f_arg_asgn f_eq value
{
Expand Down Expand Up @@ -3297,12 +3306,7 @@ command_asgn : lhs '=' lex_ctxt command_rhs
/*% ripper: defs!(*$:head[0..2], $:args, $:$) %*/
local_pop(p);
}
| backref tOP_ASGN lex_ctxt command_rhs
{
VALUE MAYBE_UNUSED(e) = rb_backref_error(p, $1);
$$ = NEW_ERROR(&@$);
/*% ripper[error]: assign_error!(?e, opassign!(var_field!($:1), $:2, $:4)) %*/
}
| backref_with_rhs(command_rhs)
;

endless_command : command
Expand Down Expand Up @@ -3874,12 +3878,7 @@ arg : lhs '=' lex_ctxt arg_rhs
$$ = new_const_op_assign(p, NEW_COLON3($2, &loc), $3, $5, $4, &@$);
/*% ripper: opassign!(top_const_field!($:2), $:3, $:5) %*/
}
| backref tOP_ASGN lex_ctxt arg_rhs
{
VALUE MAYBE_UNUSED(e) = rb_backref_error(p, $1);
$$ = NEW_ERROR(&@$);
/*% ripper[error]: assign_error!(?e, opassign!(var_field!($:1), $:2, $:4)) %*/
}
| backref_with_rhs(arg_rhs)
| arg tDOT2 arg
{
value_expr($1);
Expand Down

0 comments on commit 1686c6b

Please sign in to comment.