lib/ruby_parser.yy in ruby_parser-3.20.0 vs lib/ruby_parser.yy in ruby_parser-3.20.1

- old
+ new

@@ -251,10 +251,11 @@ result = new_masgn val[0], val[2], :wrap } | lhs tEQL mrhs { lhs, _, rhs = val + result = new_assign lhs, s(:svalue, rhs).line(rhs.line) } #if V == 20 | mlhs tEQL arg_value { @@ -1105,12 +1106,14 @@ result = new_rescue(body, new_resbody(ary, resbody)) } paren_args: tLPAREN2 opt_call_args rparen { - _, args, _ = val + _, args, (_, line_max) = val + result = args + result.line_max = line_max if args } #if V >= 27 | tLPAREN2 args tCOMMA args_forward rparen { yyerror "Unexpected ..." unless @@ -1333,16 +1336,18 @@ } | tCOLON3 tCONSTANT { result = wrap :colon3, val[1] } - | tLBRACK { result = lexer.lineno } aref_args tRBRACK + | tLBRACK { result = lexer.lineno } aref_args rbracket { - _, line, args, _ = val + _, line, args, (_, line_max) = val + result = args || s(:array) result.sexp_type = :array # aref_args is :args result.line line + result.line_max = line_max } | tLBRACE { result = self.lexer.lineno } @@ -1940,17 +1945,23 @@ method_call: fcall paren_args { call, args = val - result = call.concat args.sexp_body if args + result = call + + if args then + call.concat args.sexp_body + result.line_max = args.line_max + end } | primary_value call_op operation2 opt_paren_args { - recv, call_op, (op, _line), args = val + recv, call_op, (op, op_line), args = val result = new_call recv, op.to_sym, args, call_op + result.line_max = op_line unless args } | primary_value tCOLON2 operation2 paren_args { recv, _, (op, _line), args = val @@ -2672,19 +2683,21 @@ result = new_regexp val } words: tWORDS_BEG tSPACE tSTRING_END { - (_, line), _, _ = val + (_, line), _, (_, line_max) = val result = s(:array).line line + result.line_max = line_max } | tWORDS_BEG word_list tSTRING_END { - (_, line), list, _ = val + (_, line), list, (_, line_max) = val result = list.line line + result.line_max = line_max } word_list: none { result = new_word_list @@ -2700,19 +2713,21 @@ result = self.literal_concat val[0], val[1] } symbols: tSYMBOLS_BEG tSPACE tSTRING_END { - (_, line), _, _ = val + (_, line), _, (_, line_max) = val result = s(:array).line line + result.line_max = line_max } | tSYMBOLS_BEG symbol_list tSTRING_END { - (_, line), list, _, = val - list.line line - result = list + (_, line), list, (_, line_max), = val + + result = list.line line + result.line_max = line_max } symbol_list: none { result = new_symbol_list @@ -2723,32 +2738,36 @@ result = list.dup << new_symbol_list_entry(val) } qwords: tQWORDS_BEG tSPACE tSTRING_END { - (_, line), _, _ = val + (_, line), _, (_, line_max) = val result = s(:array).line line + result.line_max = line_max } | tQWORDS_BEG qword_list tSTRING_END { - (_, line), list, _ = val + (_, line), list, (_, line_max) = val result = list.line line + result.line_max = line_max } qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END { - (_, line), _, _ = val + (_, line), _, (_, line_max) = val result = s(:array).line line + result.line_max = line_max } | tQSYMBOLS_BEG qsym_list tSTRING_END { - (_, line), list, _ = val + (_, line), list, (_, line_max) = val result = list.line line + result.line_max = line_max } qword_list: none { result = new_qword_list @@ -3195,11 +3214,18 @@ result = list else result = s(:args, list).line list.line end - result << (Sexp === item ? item : item.first) + if Sexp === item then + line_max = item.line_max + else + item, line_max = item + end + + result << item + result.line_max = line_max } #if V == 20 f_kw: tLABEL arg_value #else @@ -3447,10 +3473,18 @@ | tCOLON2 opt_terms: | terms opt_nl: | tNL rparen: opt_nl tRPAREN + { + _, close = val + result = [close, lexer.lineno] + } rbracket: opt_nl tRBRACK + { + _, close = val + result = [close, lexer.lineno] + } #if V >= 27 rbrace: opt_nl tRCURLY #endif trailer: | tNL | tCOMMA