From 5b9e5b19f405798daa75f45fb8d800841ff3b80c Mon Sep 17 00:00:00 2001 From: Ilya Bylich Date: Wed, 27 Dec 2023 20:17:54 +0100 Subject: [PATCH] * ruby33.y: extract {endless_command,endless_arg} rules --- lib/parser/ruby33.y | 96 ++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 70 deletions(-) diff --git a/lib/parser/ruby33.y b/lib/parser/ruby33.y index d4c1e24cd..aa8a4fdc7 100644 --- a/lib/parser/ruby33.y +++ b/lib/parser/ruby33.y @@ -261,7 +261,7 @@ rule val[0], val[1], val[2]), val[3], val[4]) } - | defn_head f_opt_paren_args tEQL command + | defn_head f_opt_paren_args tEQL endless_command { def_t, (name_t, ctx) = val[0] endless_method_name(name_t) @@ -273,25 +273,7 @@ rule @current_arg_stack.pop @context.in_def = ctx.in_def } - | defn_head f_opt_paren_args tEQL command kRESCUE_MOD arg - { - def_t, (name_t, ctx) = val[0] - endless_method_name(name_t) - - rescue_body = @builder.rescue_body(val[4], - nil, nil, nil, - nil, val[5]) - - method_body = @builder.begin_body(val[3], [ rescue_body ]) - - result = @builder.def_endless_method(def_t, name_t, - val[1], val[2], method_body) - - local_pop - @current_arg_stack.pop - @context.in_def = ctx.in_def - } - | defs_head f_opt_paren_args tEQL command + | defs_head f_opt_paren_args tEQL endless_command { def_t, recv, dot_t, (name_t, ctx) = val[0] endless_method_name(name_t) @@ -303,27 +285,23 @@ rule @current_arg_stack.pop @context.in_def = ctx.in_def } - | defs_head f_opt_paren_args tEQL command kRESCUE_MOD arg + | backref tOP_ASGN command_rhs { - def_t, recv, dot_t, (name_t, ctx) = val[0] - endless_method_name(name_t) + @builder.op_assign(val[0], val[1], val[2]) + } - rescue_body = @builder.rescue_body(val[4], + endless_command: command + | endless_command kRESCUE_MOD arg + { + rescue_body = @builder.rescue_body(val[1], nil, nil, nil, - nil, val[5]) - - method_body = @builder.begin_body(val[3], [ rescue_body ]) - - result = @builder.def_endless_singleton(def_t, recv, dot_t, name_t, - val[1], val[2], method_body) + nil, val[2]) - local_pop - @current_arg_stack.pop - @context.in_def = ctx.in_def + result = @builder.begin_body(val[0], [ rescue_body ]) } - | backref tOP_ASGN command_rhs + | kNOT opt_nl endless_command { - @builder.op_assign(val[0], val[1], val[2]) + result = @builder.not_op(val[0], nil, val[2], nil) } command_rhs: command_call =tOP_ASGN @@ -939,7 +917,7 @@ rule result = @builder.ternary(val[0], val[1], val[2], val[4], val[5]) } - | defn_head f_opt_paren_args tEQL arg + | defn_head f_opt_paren_args tEQL endless_arg { def_t, (name_t, ctx) = val[0] endless_method_name(name_t) @@ -951,25 +929,7 @@ rule @current_arg_stack.pop @context.in_def = ctx.in_def } - | defn_head f_opt_paren_args tEQL arg kRESCUE_MOD arg - { - def_t, (name_t, ctx) = val[0] - endless_method_name(name_t) - - rescue_body = @builder.rescue_body(val[4], - nil, nil, nil, - nil, val[5]) - - method_body = @builder.begin_body(val[3], [ rescue_body ]) - - result = @builder.def_endless_method(def_t, name_t, - val[1], val[2], method_body) - - local_pop - @current_arg_stack.pop - @context.in_def = ctx.in_def - } - | defs_head f_opt_paren_args tEQL arg + | defs_head f_opt_paren_args tEQL endless_arg { def_t, recv, dot_t, (name_t, ctx) = val[0] endless_method_name(name_t) @@ -981,25 +941,21 @@ rule @current_arg_stack.pop @context.in_def = ctx.in_def } - | defs_head f_opt_paren_args tEQL arg kRESCUE_MOD arg - { - def_t, recv, dot_t, (name_t, ctx) = val[0] - endless_method_name(name_t) + | primary - rescue_body = @builder.rescue_body(val[4], + endless_arg: arg=kRESCUE_MOD + | endless_arg kRESCUE_MOD arg + { + rescue_body = @builder.rescue_body(val[1], nil, nil, nil, - nil, val[5]) - - method_body = @builder.begin_body(val[3], [ rescue_body ]) - - result = @builder.def_endless_singleton(def_t, recv, dot_t, name_t, - val[1], val[2], method_body) + nil, val[2]) - local_pop - @current_arg_stack.pop - @context.in_def = ctx.in_def + result = @builder.begin_body(val[0], [ rescue_body ]) + } + | kNOT opt_nl endless_arg + { + result = @builder.not_op(val[0], nil, val[2], nil) } - | primary relop: tGT | tLT | tGEQ | tLEQ