Use user defined parameterizing rules range_expr
This commit is contained in:
parent
088fd968ed
commit
e255964542
Notes:
git
2025-04-13 18:21:34 +00:00
116
parse.y
116
parse.y
@ -2793,7 +2793,7 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
|
|||||||
%type <node> p_case_body p_cases p_top_expr p_top_expr_body
|
%type <node> p_case_body p_cases p_top_expr p_top_expr_body
|
||||||
%type <node> p_expr p_as p_alt p_expr_basic p_find
|
%type <node> p_expr p_as p_alt p_expr_basic p_find
|
||||||
%type <node> p_args p_args_head p_args_tail p_args_post p_arg p_rest
|
%type <node> p_args p_args_head p_args_tail p_args_post p_arg p_rest
|
||||||
%type <node> p_value p_primitive p_primitive_value p_variable p_var_ref p_expr_ref p_const
|
%type <node> p_value p_primitive p_variable p_var_ref p_expr_ref p_const
|
||||||
%type <node> p_kwargs p_kwarg p_kw
|
%type <node> p_kwargs p_kwarg p_kw
|
||||||
%type <id> keyword_variable user_variable sym operation2 operation3
|
%type <id> keyword_variable user_variable sym 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> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
|
||||||
@ -3097,6 +3097,47 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
%rule range_expr(range) <node>
|
||||||
|
: range tDOT2 range
|
||||||
|
{
|
||||||
|
value_expr($1);
|
||||||
|
value_expr($3);
|
||||||
|
$$ = NEW_DOT2($1, $3, &@$, &@2);
|
||||||
|
/*% ripper: dot2!($:1, $:3) %*/
|
||||||
|
}
|
||||||
|
| range tDOT3 range
|
||||||
|
{
|
||||||
|
value_expr($1);
|
||||||
|
value_expr($3);
|
||||||
|
$$ = NEW_DOT3($1, $3, &@$, &@2);
|
||||||
|
/*% ripper: dot3!($:1, $:3) %*/
|
||||||
|
}
|
||||||
|
| range tDOT2
|
||||||
|
{
|
||||||
|
value_expr($1);
|
||||||
|
$$ = NEW_DOT2($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
|
||||||
|
/*% ripper: dot2!($:1, Qnil) %*/
|
||||||
|
}
|
||||||
|
| range tDOT3
|
||||||
|
{
|
||||||
|
value_expr($1);
|
||||||
|
$$ = NEW_DOT3($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
|
||||||
|
/*% ripper: dot3!($:1, Qnil) %*/
|
||||||
|
}
|
||||||
|
| tBDOT2 range
|
||||||
|
{
|
||||||
|
value_expr($2);
|
||||||
|
$$ = NEW_DOT2(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
|
||||||
|
/*% ripper: dot2!(Qnil, $:2) %*/
|
||||||
|
}
|
||||||
|
| tBDOT3 range
|
||||||
|
{
|
||||||
|
value_expr($2);
|
||||||
|
$$ = NEW_DOT3(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
|
||||||
|
/*% ripper: dot3!(Qnil, $:2) %*/
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
%rule value_expr(value) <node>
|
%rule value_expr(value) <node>
|
||||||
: value
|
: value
|
||||||
{
|
{
|
||||||
@ -3874,44 +3915,7 @@ reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
|
|||||||
|
|
||||||
arg : asgn(arg_rhs)
|
arg : asgn(arg_rhs)
|
||||||
| op_asgn(arg_rhs)
|
| op_asgn(arg_rhs)
|
||||||
| arg tDOT2 arg
|
| range_expr(arg)
|
||||||
{
|
|
||||||
value_expr($1);
|
|
||||||
value_expr($3);
|
|
||||||
$$ = NEW_DOT2($1, $3, &@$, &@2);
|
|
||||||
/*% ripper: dot2!($:1, $:3) %*/
|
|
||||||
}
|
|
||||||
| arg tDOT3 arg
|
|
||||||
{
|
|
||||||
value_expr($1);
|
|
||||||
value_expr($3);
|
|
||||||
$$ = NEW_DOT3($1, $3, &@$, &@2);
|
|
||||||
/*% ripper: dot3!($:1, $:3) %*/
|
|
||||||
}
|
|
||||||
| arg tDOT2
|
|
||||||
{
|
|
||||||
value_expr($1);
|
|
||||||
$$ = NEW_DOT2($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
|
|
||||||
/*% ripper: dot2!($:1, Qnil) %*/
|
|
||||||
}
|
|
||||||
| arg tDOT3
|
|
||||||
{
|
|
||||||
value_expr($1);
|
|
||||||
$$ = NEW_DOT3($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
|
|
||||||
/*% ripper: dot3!($:1, Qnil) %*/
|
|
||||||
}
|
|
||||||
| tBDOT2 arg
|
|
||||||
{
|
|
||||||
value_expr($2);
|
|
||||||
$$ = NEW_DOT2(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
|
|
||||||
/*% ripper: dot2!(Qnil, $:2) %*/
|
|
||||||
}
|
|
||||||
| tBDOT3 arg
|
|
||||||
{
|
|
||||||
value_expr($2);
|
|
||||||
$$ = NEW_DOT3(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
|
|
||||||
/*% ripper: dot3!(Qnil, $:2) %*/
|
|
||||||
}
|
|
||||||
| arg '+' arg
|
| arg '+' arg
|
||||||
{
|
{
|
||||||
$$ = call_bin_op(p, $1, '+', $3, &@2, &@$);
|
$$ = call_bin_op(p, $1, '+', $3, &@2, &@$);
|
||||||
@ -5761,39 +5765,10 @@ p_any_kwrest : p_kwrest
|
|||||||
;
|
;
|
||||||
|
|
||||||
p_value : p_primitive
|
p_value : p_primitive
|
||||||
| p_primitive_value tDOT2 p_primitive_value
|
| range_expr(p_primitive)
|
||||||
{
|
|
||||||
$$ = NEW_DOT2($1, $3, &@$, &@2);
|
|
||||||
/*% ripper: dot2!($:1, $:3) %*/
|
|
||||||
}
|
|
||||||
| p_primitive_value tDOT3 p_primitive_value
|
|
||||||
{
|
|
||||||
$$ = NEW_DOT3($1, $3, &@$, &@2);
|
|
||||||
/*% ripper: dot3!($:1, $:3) %*/
|
|
||||||
}
|
|
||||||
| p_primitive_value tDOT2
|
|
||||||
{
|
|
||||||
$$ = NEW_DOT2($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
|
|
||||||
/*% ripper: dot2!($:1, Qnil) %*/
|
|
||||||
}
|
|
||||||
| p_primitive_value tDOT3
|
|
||||||
{
|
|
||||||
$$ = NEW_DOT3($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
|
|
||||||
/*% ripper: dot3!($:1, Qnil) %*/
|
|
||||||
}
|
|
||||||
| p_var_ref
|
| p_var_ref
|
||||||
| p_expr_ref
|
| p_expr_ref
|
||||||
| p_const
|
| p_const
|
||||||
| tBDOT2 p_primitive_value
|
|
||||||
{
|
|
||||||
$$ = NEW_DOT2(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
|
|
||||||
/*% ripper: dot2!(Qnil, $:2) %*/
|
|
||||||
}
|
|
||||||
| tBDOT3 p_primitive_value
|
|
||||||
{
|
|
||||||
$$ = NEW_DOT3(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
|
|
||||||
/*% ripper: dot3!(Qnil, $:2) %*/
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
p_primitive : inline_primary
|
p_primitive : inline_primary
|
||||||
@ -5805,9 +5780,6 @@ p_primitive : inline_primary
|
|||||||
| lambda
|
| lambda
|
||||||
;
|
;
|
||||||
|
|
||||||
p_primitive_value : value_expr(p_primitive)
|
|
||||||
;
|
|
||||||
|
|
||||||
p_variable : tIDENTIFIER
|
p_variable : tIDENTIFIER
|
||||||
{
|
{
|
||||||
error_duplicate_pattern_variable(p, $1, &@1);
|
error_duplicate_pattern_variable(p, $1, &@1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user