ruby_parser 3.20.0 → 3.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +6 -0
- data/lib/ruby20_parser.rb +170 -134
- data/lib/ruby20_parser.y +50 -16
- data/lib/ruby21_parser.rb +110 -74
- data/lib/ruby21_parser.y +50 -16
- data/lib/ruby22_parser.rb +238 -202
- data/lib/ruby22_parser.y +50 -16
- data/lib/ruby23_parser.rb +383 -347
- data/lib/ruby23_parser.y +50 -16
- data/lib/ruby24_parser.rb +96 -60
- data/lib/ruby24_parser.y +50 -16
- data/lib/ruby25_parser.rb +92 -56
- data/lib/ruby25_parser.y +50 -16
- data/lib/ruby26_parser.rb +92 -56
- data/lib/ruby26_parser.y +50 -16
- data/lib/ruby27_parser.rb +574 -538
- data/lib/ruby27_parser.y +50 -16
- data/lib/ruby30_parser.rb +357 -331
- data/lib/ruby30_parser.y +42 -16
- data/lib/ruby31_parser.rb +174 -148
- data/lib/ruby31_parser.y +42 -16
- data/lib/ruby32_parser.rb +174 -148
- data/lib/ruby32_parser.y +42 -16
- data/lib/ruby3_parser.yy +42 -16
- data/lib/ruby_parser.yy +50 -16
- data/lib/ruby_parser_extras.rb +19 -13
- data/test/test_ruby_parser.rb +156 -6
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
    
        data/lib/ruby32_parser.y
    CHANGED
    
    | @@ -221,6 +221,7 @@ rule | |
| 221 221 | 
             
                            | lhs tEQL mrhs
         | 
| 222 222 | 
             
                                {
         | 
| 223 223 | 
             
                                  lhs, _, rhs = val
         | 
| 224 | 
            +
             | 
| 224 225 | 
             
                                  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
         | 
| 225 226 | 
             
                                }
         | 
| 226 227 | 
             
                            | mlhs tEQL mrhs_arg kRESCUE_MOD stmt
         | 
| @@ -1130,8 +1131,10 @@ rule | |
| 1130 1131 |  | 
| 1131 1132 | 
             
                  paren_args: tLPAREN2 opt_call_args rparen
         | 
| 1132 1133 | 
             
                                {
         | 
| 1133 | 
            -
                                  _, args, _ = val
         | 
| 1134 | 
            +
                                  _, args, (_, line_max) = val
         | 
| 1135 | 
            +
             | 
| 1134 1136 | 
             
                                  result = args
         | 
| 1137 | 
            +
                                  result.line_max = line_max if args
         | 
| 1135 1138 | 
             
                                }
         | 
| 1136 1139 | 
             
                            | tLPAREN2 args tCOMMA args_forward rparen
         | 
| 1137 1140 | 
             
                                {
         | 
| @@ -1359,12 +1362,14 @@ rule | |
| 1359 1362 | 
             
                                {
         | 
| 1360 1363 | 
             
                                  result = wrap :colon3, val[1]
         | 
| 1361 1364 | 
             
                                }
         | 
| 1362 | 
            -
                            | tLBRACK { result = lexer.lineno } aref_args  | 
| 1365 | 
            +
                            | tLBRACK { result = lexer.lineno } aref_args rbracket
         | 
| 1363 1366 | 
             
                                {
         | 
| 1364 | 
            -
                                  _, line, args, _ = val
         | 
| 1367 | 
            +
                                  _, line, args, (_, line_max) = val
         | 
| 1368 | 
            +
             | 
| 1365 1369 | 
             
                                  result = args || s(:array)
         | 
| 1366 1370 | 
             
                                  result.sexp_type = :array # aref_args is :args
         | 
| 1367 1371 | 
             
                                  result.line line
         | 
| 1372 | 
            +
                                  result.line_max = line_max
         | 
| 1368 1373 | 
             
                                }
         | 
| 1369 1374 | 
             
                            | tLBRACE
         | 
| 1370 1375 | 
             
                                {
         | 
| @@ -1953,13 +1958,19 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 1953 1958 | 
             
                                {
         | 
| 1954 1959 | 
             
                                  call, args = val
         | 
| 1955 1960 |  | 
| 1956 | 
            -
                                  result = call | 
| 1961 | 
            +
                                  result = call
         | 
| 1962 | 
            +
             | 
| 1963 | 
            +
                                  if args then
         | 
| 1964 | 
            +
                                    call.concat args.sexp_body
         | 
| 1965 | 
            +
                                    result.line_max = args.line_max
         | 
| 1966 | 
            +
                                  end
         | 
| 1957 1967 | 
             
                                }
         | 
| 1958 1968 | 
             
                            | primary_value call_op operation2 opt_paren_args
         | 
| 1959 1969 | 
             
                                {
         | 
| 1960 | 
            -
                                  recv, call_op, (op,  | 
| 1970 | 
            +
                                  recv, call_op, (op, op_line), args = val
         | 
| 1961 1971 |  | 
| 1962 1972 | 
             
                                  result = new_call recv, op.to_sym, args, call_op
         | 
| 1973 | 
            +
                                  result.line_max = op_line unless args
         | 
| 1963 1974 | 
             
                                }
         | 
| 1964 1975 | 
             
                            | primary_value tCOLON2 operation2 paren_args
         | 
| 1965 1976 | 
             
                                {
         | 
| @@ -2716,15 +2727,17 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2716 2727 |  | 
| 2717 2728 | 
             
                       words: tWORDS_BEG tSPACE tSTRING_END
         | 
| 2718 2729 | 
             
                                {
         | 
| 2719 | 
            -
                                  (_, line), _, _ = val
         | 
| 2730 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2720 2731 |  | 
| 2721 2732 | 
             
                                  result = s(:array).line line
         | 
| 2733 | 
            +
                                  result.line_max = line_max
         | 
| 2722 2734 | 
             
                                }
         | 
| 2723 2735 | 
             
                            | tWORDS_BEG word_list tSTRING_END
         | 
| 2724 2736 | 
             
                                {
         | 
| 2725 | 
            -
                                  (_, line), list, _ = val
         | 
| 2737 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2726 2738 |  | 
| 2727 2739 | 
             
                                  result = list.line line
         | 
| 2740 | 
            +
                                  result.line_max = line_max
         | 
| 2728 2741 | 
             
                                }
         | 
| 2729 2742 |  | 
| 2730 2743 | 
             
                   word_list: none
         | 
| @@ -2744,15 +2757,17 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2744 2757 |  | 
| 2745 2758 | 
             
                     symbols: tSYMBOLS_BEG tSPACE tSTRING_END
         | 
| 2746 2759 | 
             
                                {
         | 
| 2747 | 
            -
                                  (_, line), _, _ = val
         | 
| 2760 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2748 2761 |  | 
| 2749 2762 | 
             
                                  result = s(:array).line line
         | 
| 2763 | 
            +
                                  result.line_max = line_max
         | 
| 2750 2764 | 
             
                                }
         | 
| 2751 2765 | 
             
                            | tSYMBOLS_BEG symbol_list tSTRING_END
         | 
| 2752 2766 | 
             
                                {
         | 
| 2753 | 
            -
                                  (_, line), list, _, = val
         | 
| 2754 | 
            -
             | 
| 2755 | 
            -
                                  result = list
         | 
| 2767 | 
            +
                                  (_, line), list, (_, line_max), = val
         | 
| 2768 | 
            +
             | 
| 2769 | 
            +
                                  result = list.line line
         | 
| 2770 | 
            +
                                  result.line_max = line_max
         | 
| 2756 2771 | 
             
                                }
         | 
| 2757 2772 |  | 
| 2758 2773 | 
             
                 symbol_list: none
         | 
| @@ -2767,28 +2782,32 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2767 2782 |  | 
| 2768 2783 | 
             
                      qwords: tQWORDS_BEG tSPACE tSTRING_END
         | 
| 2769 2784 | 
             
                                {
         | 
| 2770 | 
            -
                                  (_, line), _, _ = val
         | 
| 2785 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2771 2786 |  | 
| 2772 2787 | 
             
                                  result = s(:array).line line
         | 
| 2788 | 
            +
                                  result.line_max = line_max
         | 
| 2773 2789 | 
             
                                }
         | 
| 2774 2790 | 
             
                            | tQWORDS_BEG qword_list tSTRING_END
         | 
| 2775 2791 | 
             
                                {
         | 
| 2776 | 
            -
                                  (_, line), list, _ = val
         | 
| 2792 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2777 2793 |  | 
| 2778 2794 | 
             
                                  result = list.line line
         | 
| 2795 | 
            +
                                  result.line_max = line_max
         | 
| 2779 2796 | 
             
                                }
         | 
| 2780 2797 |  | 
| 2781 2798 | 
             
                    qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
         | 
| 2782 2799 | 
             
                                {
         | 
| 2783 | 
            -
                                  (_, line), _, _ = val
         | 
| 2800 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2784 2801 |  | 
| 2785 2802 | 
             
                                  result = s(:array).line line
         | 
| 2803 | 
            +
                                  result.line_max = line_max
         | 
| 2786 2804 | 
             
                                }
         | 
| 2787 2805 | 
             
                            | tQSYMBOLS_BEG qsym_list tSTRING_END
         | 
| 2788 2806 | 
             
                                {
         | 
| 2789 | 
            -
                                  (_, line), list, _ = val
         | 
| 2807 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2790 2808 |  | 
| 2791 2809 | 
             
                                  result = list.line line
         | 
| 2810 | 
            +
                                  result.line_max = line_max
         | 
| 2792 2811 | 
             
                                }
         | 
| 2793 2812 |  | 
| 2794 2813 | 
             
                  qword_list: none
         | 
| @@ -3210,7 +3229,14 @@ f_opt_paren_args: f_paren_args | |
| 3210 3229 | 
             
                                    result = s(:args, list).line list.line
         | 
| 3211 3230 | 
             
                                  end
         | 
| 3212 3231 |  | 
| 3213 | 
            -
                                   | 
| 3232 | 
            +
                                  if Sexp === item then
         | 
| 3233 | 
            +
                                    line_max = item.line_max
         | 
| 3234 | 
            +
                                  else
         | 
| 3235 | 
            +
                                    item, line_max = item
         | 
| 3236 | 
            +
                                  end
         | 
| 3237 | 
            +
             | 
| 3238 | 
            +
                                  result << item
         | 
| 3239 | 
            +
                                  result.line_max = line_max
         | 
| 3214 3240 | 
             
                                }
         | 
| 3215 3241 |  | 
| 3216 3242 | 
             
                     f_label: tLABEL
         | 
    
        data/lib/ruby3_parser.yy
    CHANGED
    
    | @@ -229,6 +229,7 @@ rule | |
| 229 229 | 
             
                            | lhs tEQL mrhs
         | 
| 230 230 | 
             
                                {
         | 
| 231 231 | 
             
                                  lhs, _, rhs = val
         | 
| 232 | 
            +
             | 
| 232 233 | 
             
                                  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
         | 
| 233 234 | 
             
                                }
         | 
| 234 235 | 
             
                            | mlhs tEQL mrhs_arg kRESCUE_MOD stmt
         | 
| @@ -1148,8 +1149,10 @@ rule | |
| 1148 1149 |  | 
| 1149 1150 | 
             
                  paren_args: tLPAREN2 opt_call_args rparen
         | 
| 1150 1151 | 
             
                                {
         | 
| 1151 | 
            -
                                  _, args, _ = val
         | 
| 1152 | 
            +
                                  _, args, (_, line_max) = val
         | 
| 1153 | 
            +
             | 
| 1152 1154 | 
             
                                  result = args
         | 
| 1155 | 
            +
                                  result.line_max = line_max if args
         | 
| 1153 1156 | 
             
                                }
         | 
| 1154 1157 | 
             
                            | tLPAREN2 args tCOMMA args_forward rparen
         | 
| 1155 1158 | 
             
                                {
         | 
| @@ -1379,12 +1382,14 @@ rule | |
| 1379 1382 | 
             
                                {
         | 
| 1380 1383 | 
             
                                  result = wrap :colon3, val[1]
         | 
| 1381 1384 | 
             
                                }
         | 
| 1382 | 
            -
                            | tLBRACK { result = lexer.lineno } aref_args  | 
| 1385 | 
            +
                            | tLBRACK { result = lexer.lineno } aref_args rbracket
         | 
| 1383 1386 | 
             
                                {
         | 
| 1384 | 
            -
                                  _, line, args, _ = val
         | 
| 1387 | 
            +
                                  _, line, args, (_, line_max) = val
         | 
| 1388 | 
            +
             | 
| 1385 1389 | 
             
                                  result = args || s(:array)
         | 
| 1386 1390 | 
             
                                  result.sexp_type = :array # aref_args is :args
         | 
| 1387 1391 | 
             
                                  result.line line
         | 
| 1392 | 
            +
                                  result.line_max = line_max
         | 
| 1388 1393 | 
             
                                }
         | 
| 1389 1394 | 
             
                            | tLBRACE
         | 
| 1390 1395 | 
             
                                {
         | 
| @@ -1975,13 +1980,19 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 1975 1980 | 
             
                                {
         | 
| 1976 1981 | 
             
                                  call, args = val
         | 
| 1977 1982 |  | 
| 1978 | 
            -
                                  result = call | 
| 1983 | 
            +
                                  result = call
         | 
| 1984 | 
            +
             | 
| 1985 | 
            +
                                  if args then
         | 
| 1986 | 
            +
                                    call.concat args.sexp_body
         | 
| 1987 | 
            +
                                    result.line_max = args.line_max
         | 
| 1988 | 
            +
                                  end
         | 
| 1979 1989 | 
             
                                }
         | 
| 1980 1990 | 
             
                            | primary_value call_op operation2 opt_paren_args
         | 
| 1981 1991 | 
             
                                {
         | 
| 1982 | 
            -
                                  recv, call_op, (op,  | 
| 1992 | 
            +
                                  recv, call_op, (op, op_line), args = val
         | 
| 1983 1993 |  | 
| 1984 1994 | 
             
                                  result = new_call recv, op.to_sym, args, call_op
         | 
| 1995 | 
            +
                                  result.line_max = op_line unless args
         | 
| 1985 1996 | 
             
                                }
         | 
| 1986 1997 | 
             
                            | primary_value tCOLON2 operation2 paren_args
         | 
| 1987 1998 | 
             
                                {
         | 
| @@ -2751,15 +2762,17 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2751 2762 |  | 
| 2752 2763 | 
             
                       words: tWORDS_BEG tSPACE tSTRING_END
         | 
| 2753 2764 | 
             
                                {
         | 
| 2754 | 
            -
                                  (_, line), _, _ = val
         | 
| 2765 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2755 2766 |  | 
| 2756 2767 | 
             
                                  result = s(:array).line line
         | 
| 2768 | 
            +
                                  result.line_max = line_max
         | 
| 2757 2769 | 
             
                                }
         | 
| 2758 2770 | 
             
                            | tWORDS_BEG word_list tSTRING_END
         | 
| 2759 2771 | 
             
                                {
         | 
| 2760 | 
            -
                                  (_, line), list, _ = val
         | 
| 2772 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2761 2773 |  | 
| 2762 2774 | 
             
                                  result = list.line line
         | 
| 2775 | 
            +
                                  result.line_max = line_max
         | 
| 2763 2776 | 
             
                                }
         | 
| 2764 2777 |  | 
| 2765 2778 | 
             
                   word_list: none
         | 
| @@ -2779,15 +2792,17 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2779 2792 |  | 
| 2780 2793 | 
             
                     symbols: tSYMBOLS_BEG tSPACE tSTRING_END
         | 
| 2781 2794 | 
             
                                {
         | 
| 2782 | 
            -
                                  (_, line), _, _ = val
         | 
| 2795 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2783 2796 |  | 
| 2784 2797 | 
             
                                  result = s(:array).line line
         | 
| 2798 | 
            +
                                  result.line_max = line_max
         | 
| 2785 2799 | 
             
                                }
         | 
| 2786 2800 | 
             
                            | tSYMBOLS_BEG symbol_list tSTRING_END
         | 
| 2787 2801 | 
             
                                {
         | 
| 2788 | 
            -
                                  (_, line), list, _, = val
         | 
| 2789 | 
            -
             | 
| 2790 | 
            -
                                  result = list
         | 
| 2802 | 
            +
                                  (_, line), list, (_, line_max), = val
         | 
| 2803 | 
            +
             | 
| 2804 | 
            +
                                  result = list.line line
         | 
| 2805 | 
            +
                                  result.line_max = line_max
         | 
| 2791 2806 | 
             
                                }
         | 
| 2792 2807 |  | 
| 2793 2808 | 
             
                 symbol_list: none
         | 
| @@ -2802,28 +2817,32 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2802 2817 |  | 
| 2803 2818 | 
             
                      qwords: tQWORDS_BEG tSPACE tSTRING_END
         | 
| 2804 2819 | 
             
                                {
         | 
| 2805 | 
            -
                                  (_, line), _, _ = val
         | 
| 2820 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2806 2821 |  | 
| 2807 2822 | 
             
                                  result = s(:array).line line
         | 
| 2823 | 
            +
                                  result.line_max = line_max
         | 
| 2808 2824 | 
             
                                }
         | 
| 2809 2825 | 
             
                            | tQWORDS_BEG qword_list tSTRING_END
         | 
| 2810 2826 | 
             
                                {
         | 
| 2811 | 
            -
                                  (_, line), list, _ = val
         | 
| 2827 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2812 2828 |  | 
| 2813 2829 | 
             
                                  result = list.line line
         | 
| 2830 | 
            +
                                  result.line_max = line_max
         | 
| 2814 2831 | 
             
                                }
         | 
| 2815 2832 |  | 
| 2816 2833 | 
             
                    qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
         | 
| 2817 2834 | 
             
                                {
         | 
| 2818 | 
            -
                                  (_, line), _, _ = val
         | 
| 2835 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2819 2836 |  | 
| 2820 2837 | 
             
                                  result = s(:array).line line
         | 
| 2838 | 
            +
                                  result.line_max = line_max
         | 
| 2821 2839 | 
             
                                }
         | 
| 2822 2840 | 
             
                            | tQSYMBOLS_BEG qsym_list tSTRING_END
         | 
| 2823 2841 | 
             
                                {
         | 
| 2824 | 
            -
                                  (_, line), list, _ = val
         | 
| 2842 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2825 2843 |  | 
| 2826 2844 | 
             
                                  result = list.line line
         | 
| 2845 | 
            +
                                  result.line_max = line_max
         | 
| 2827 2846 | 
             
                                }
         | 
| 2828 2847 |  | 
| 2829 2848 | 
             
                  qword_list: none
         | 
| @@ -3259,7 +3278,14 @@ f_opt_paren_args: f_paren_args | |
| 3259 3278 | 
             
                                    result = s(:args, list).line list.line
         | 
| 3260 3279 | 
             
                                  end
         | 
| 3261 3280 |  | 
| 3262 | 
            -
                                   | 
| 3281 | 
            +
                                  if Sexp === item then
         | 
| 3282 | 
            +
                                    line_max = item.line_max
         | 
| 3283 | 
            +
                                  else
         | 
| 3284 | 
            +
                                    item, line_max = item
         | 
| 3285 | 
            +
                                  end
         | 
| 3286 | 
            +
             | 
| 3287 | 
            +
                                  result << item
         | 
| 3288 | 
            +
                                  result.line_max = line_max
         | 
| 3263 3289 | 
             
                                }
         | 
| 3264 3290 |  | 
| 3265 3291 | 
             
                     f_label: tLABEL
         | 
    
        data/lib/ruby_parser.yy
    CHANGED
    
    | @@ -253,6 +253,7 @@ rule | |
| 253 253 | 
             
                            | lhs tEQL mrhs
         | 
| 254 254 | 
             
                                {
         | 
| 255 255 | 
             
                                  lhs, _, rhs = val
         | 
| 256 | 
            +
             | 
| 256 257 | 
             
                                  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
         | 
| 257 258 | 
             
                                }
         | 
| 258 259 | 
             
            #if V == 20
         | 
| @@ -1107,8 +1108,10 @@ rule | |
| 1107 1108 |  | 
| 1108 1109 | 
             
                  paren_args: tLPAREN2 opt_call_args rparen
         | 
| 1109 1110 | 
             
                                {
         | 
| 1110 | 
            -
                                  _, args, _ = val
         | 
| 1111 | 
            +
                                  _, args, (_, line_max) = val
         | 
| 1112 | 
            +
             | 
| 1111 1113 | 
             
                                  result = args
         | 
| 1114 | 
            +
                                  result.line_max = line_max if args
         | 
| 1112 1115 | 
             
                                }
         | 
| 1113 1116 | 
             
            #if V >= 27
         | 
| 1114 1117 | 
             
                            | tLPAREN2 args tCOMMA args_forward rparen
         | 
| @@ -1335,12 +1338,14 @@ rule | |
| 1335 1338 | 
             
                                {
         | 
| 1336 1339 | 
             
                                  result = wrap :colon3, val[1]
         | 
| 1337 1340 | 
             
                                }
         | 
| 1338 | 
            -
                            | tLBRACK { result = lexer.lineno } aref_args  | 
| 1341 | 
            +
                            | tLBRACK { result = lexer.lineno } aref_args rbracket
         | 
| 1339 1342 | 
             
                                {
         | 
| 1340 | 
            -
                                  _, line, args, _ = val
         | 
| 1343 | 
            +
                                  _, line, args, (_, line_max) = val
         | 
| 1344 | 
            +
             | 
| 1341 1345 | 
             
                                  result = args || s(:array)
         | 
| 1342 1346 | 
             
                                  result.sexp_type = :array # aref_args is :args
         | 
| 1343 1347 | 
             
                                  result.line line
         | 
| 1348 | 
            +
                                  result.line_max = line_max
         | 
| 1344 1349 | 
             
                                }
         | 
| 1345 1350 | 
             
                            | tLBRACE
         | 
| 1346 1351 | 
             
                                {
         | 
| @@ -1942,13 +1947,19 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 1942 1947 | 
             
                                {
         | 
| 1943 1948 | 
             
                                  call, args = val
         | 
| 1944 1949 |  | 
| 1945 | 
            -
                                  result = call | 
| 1950 | 
            +
                                  result = call
         | 
| 1951 | 
            +
             | 
| 1952 | 
            +
                                  if args then
         | 
| 1953 | 
            +
                                    call.concat args.sexp_body
         | 
| 1954 | 
            +
                                    result.line_max = args.line_max
         | 
| 1955 | 
            +
                                  end
         | 
| 1946 1956 | 
             
                                }
         | 
| 1947 1957 | 
             
                            | primary_value call_op operation2 opt_paren_args
         | 
| 1948 1958 | 
             
                                {
         | 
| 1949 | 
            -
                                  recv, call_op, (op,  | 
| 1959 | 
            +
                                  recv, call_op, (op, op_line), args = val
         | 
| 1950 1960 |  | 
| 1951 1961 | 
             
                                  result = new_call recv, op.to_sym, args, call_op
         | 
| 1962 | 
            +
                                  result.line_max = op_line unless args
         | 
| 1952 1963 | 
             
                                }
         | 
| 1953 1964 | 
             
                            | primary_value tCOLON2 operation2 paren_args
         | 
| 1954 1965 | 
             
                                {
         | 
| @@ -2674,15 +2685,17 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2674 2685 |  | 
| 2675 2686 | 
             
                       words: tWORDS_BEG tSPACE tSTRING_END
         | 
| 2676 2687 | 
             
                                {
         | 
| 2677 | 
            -
                                  (_, line), _, _ = val
         | 
| 2688 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2678 2689 |  | 
| 2679 2690 | 
             
                                  result = s(:array).line line
         | 
| 2691 | 
            +
                                  result.line_max = line_max
         | 
| 2680 2692 | 
             
                                }
         | 
| 2681 2693 | 
             
                            | tWORDS_BEG word_list tSTRING_END
         | 
| 2682 2694 | 
             
                                {
         | 
| 2683 | 
            -
                                  (_, line), list, _ = val
         | 
| 2695 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2684 2696 |  | 
| 2685 2697 | 
             
                                  result = list.line line
         | 
| 2698 | 
            +
                                  result.line_max = line_max
         | 
| 2686 2699 | 
             
                                }
         | 
| 2687 2700 |  | 
| 2688 2701 | 
             
                   word_list: none
         | 
| @@ -2702,15 +2715,17 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2702 2715 |  | 
| 2703 2716 | 
             
                     symbols: tSYMBOLS_BEG tSPACE tSTRING_END
         | 
| 2704 2717 | 
             
                                {
         | 
| 2705 | 
            -
                                  (_, line), _, _ = val
         | 
| 2718 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2706 2719 |  | 
| 2707 2720 | 
             
                                  result = s(:array).line line
         | 
| 2721 | 
            +
                                  result.line_max = line_max
         | 
| 2708 2722 | 
             
                                }
         | 
| 2709 2723 | 
             
                            | tSYMBOLS_BEG symbol_list tSTRING_END
         | 
| 2710 2724 | 
             
                                {
         | 
| 2711 | 
            -
                                  (_, line), list, _, = val
         | 
| 2712 | 
            -
             | 
| 2713 | 
            -
                                  result = list
         | 
| 2725 | 
            +
                                  (_, line), list, (_, line_max), = val
         | 
| 2726 | 
            +
             | 
| 2727 | 
            +
                                  result = list.line line
         | 
| 2728 | 
            +
                                  result.line_max = line_max
         | 
| 2714 2729 | 
             
                                }
         | 
| 2715 2730 |  | 
| 2716 2731 | 
             
                 symbol_list: none
         | 
| @@ -2725,28 +2740,32 @@ opt_block_args_tail: tCOMMA block_args_tail | |
| 2725 2740 |  | 
| 2726 2741 | 
             
                      qwords: tQWORDS_BEG tSPACE tSTRING_END
         | 
| 2727 2742 | 
             
                                {
         | 
| 2728 | 
            -
                                  (_, line), _, _ = val
         | 
| 2743 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2729 2744 |  | 
| 2730 2745 | 
             
                                  result = s(:array).line line
         | 
| 2746 | 
            +
                                  result.line_max = line_max
         | 
| 2731 2747 | 
             
                                }
         | 
| 2732 2748 | 
             
                            | tQWORDS_BEG qword_list tSTRING_END
         | 
| 2733 2749 | 
             
                                {
         | 
| 2734 | 
            -
                                  (_, line), list, _ = val
         | 
| 2750 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2735 2751 |  | 
| 2736 2752 | 
             
                                  result = list.line line
         | 
| 2753 | 
            +
                                  result.line_max = line_max
         | 
| 2737 2754 | 
             
                                }
         | 
| 2738 2755 |  | 
| 2739 2756 | 
             
                    qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
         | 
| 2740 2757 | 
             
                                {
         | 
| 2741 | 
            -
                                  (_, line), _, _ = val
         | 
| 2758 | 
            +
                                  (_, line), _, (_, line_max) = val
         | 
| 2742 2759 |  | 
| 2743 2760 | 
             
                                  result = s(:array).line line
         | 
| 2761 | 
            +
                                  result.line_max = line_max
         | 
| 2744 2762 | 
             
                                }
         | 
| 2745 2763 | 
             
                            | tQSYMBOLS_BEG qsym_list tSTRING_END
         | 
| 2746 2764 | 
             
                                {
         | 
| 2747 | 
            -
                                  (_, line), list, _ = val
         | 
| 2765 | 
            +
                                  (_, line), list, (_, line_max) = val
         | 
| 2748 2766 |  | 
| 2749 2767 | 
             
                                  result = list.line line
         | 
| 2768 | 
            +
                                  result.line_max = line_max
         | 
| 2750 2769 | 
             
                                }
         | 
| 2751 2770 |  | 
| 2752 2771 | 
             
                  qword_list: none
         | 
| @@ -3197,7 +3216,14 @@ keyword_variable: kNIL      { result = s(:nil).line lexer.lineno } | |
| 3197 3216 | 
             
                                    result = s(:args, list).line list.line
         | 
| 3198 3217 | 
             
                                  end
         | 
| 3199 3218 |  | 
| 3200 | 
            -
                                   | 
| 3219 | 
            +
                                  if Sexp === item then
         | 
| 3220 | 
            +
                                    line_max = item.line_max
         | 
| 3221 | 
            +
                                  else
         | 
| 3222 | 
            +
                                    item, line_max = item
         | 
| 3223 | 
            +
                                  end
         | 
| 3224 | 
            +
             | 
| 3225 | 
            +
                                  result << item
         | 
| 3226 | 
            +
                                  result.line_max = line_max
         | 
| 3201 3227 | 
             
                                }
         | 
| 3202 3228 |  | 
| 3203 3229 | 
             
            #if V == 20
         | 
| @@ -3449,7 +3475,15 @@ keyword_variable: kNIL      { result = s(:nil).line lexer.lineno } | |
| 3449 3475 | 
             
                   opt_terms:  | terms
         | 
| 3450 3476 | 
             
                      opt_nl:  | tNL
         | 
| 3451 3477 | 
             
                      rparen: opt_nl tRPAREN
         | 
| 3478 | 
            +
                                {
         | 
| 3479 | 
            +
                                  _, close = val
         | 
| 3480 | 
            +
                                  result = [close, lexer.lineno]
         | 
| 3481 | 
            +
                                }
         | 
| 3452 3482 | 
             
                    rbracket: opt_nl tRBRACK
         | 
| 3483 | 
            +
                                {
         | 
| 3484 | 
            +
                                  _, close = val
         | 
| 3485 | 
            +
                                  result = [close, lexer.lineno]
         | 
| 3486 | 
            +
                                }
         | 
| 3453 3487 | 
             
            #if V >= 27
         | 
| 3454 3488 | 
             
                      rbrace: opt_nl tRCURLY
         | 
| 3455 3489 | 
             
            #endif
         | 
    
        data/lib/ruby_parser_extras.rb
    CHANGED
    
    | @@ -18,7 +18,7 @@ class Sexp | |
| 18 18 | 
             
              end
         | 
| 19 19 |  | 
| 20 20 | 
             
              ##
         | 
| 21 | 
            -
              # Returns the  | 
| 21 | 
            +
              # Returns the minimum line number of the children of self.
         | 
| 22 22 |  | 
| 23 23 | 
             
              def line_min
         | 
| 24 24 | 
             
                @line_min ||= [self.deep_each.map(&:line).min, self.line].compact.min
         | 
| @@ -30,7 +30,7 @@ class Sexp | |
| 30 30 | 
             
            end
         | 
| 31 31 |  | 
| 32 32 | 
             
            module RubyParserStuff
         | 
| 33 | 
            -
              VERSION = "3.20. | 
| 33 | 
            +
              VERSION = "3.20.1"
         | 
| 34 34 |  | 
| 35 35 | 
             
              attr_accessor :lexer, :in_def, :in_single, :file
         | 
| 36 36 | 
             
              attr_accessor :in_kwarg
         | 
| @@ -153,6 +153,7 @@ module RubyParserStuff | |
| 153 153 | 
             
                  result.line lexer.lineno
         | 
| 154 154 | 
             
                else
         | 
| 155 155 | 
             
                  result.line ss.first.line
         | 
| 156 | 
            +
                  result.line_max = ss.first.line_max
         | 
| 156 157 | 
             
                end
         | 
| 157 158 |  | 
| 158 159 | 
             
                args.each do |arg|
         | 
| @@ -330,9 +331,8 @@ module RubyParserStuff | |
| 330 331 | 
             
                end
         | 
| 331 332 |  | 
| 332 333 | 
             
                args.each do |arg|
         | 
| 333 | 
            -
                   | 
| 334 | 
            -
             | 
| 335 | 
            -
                  end
         | 
| 334 | 
            +
                  # ruby 3.0+ TODO: next if arg in [String, Integer] # eg ["(", 1]
         | 
| 335 | 
            +
                  next if arg.class == Array && arg.map(&:class) == [String, Integer]
         | 
| 336 336 |  | 
| 337 337 | 
             
                  case arg
         | 
| 338 338 | 
             
                  when Sexp then
         | 
| @@ -794,6 +794,7 @@ module RubyParserStuff | |
| 794 794 | 
             
                case lhs.sexp_type
         | 
| 795 795 | 
             
                when :lasgn, :iasgn, :cdecl, :cvdecl, :gasgn, :cvasgn, :attrasgn, :safe_attrasgn then
         | 
| 796 796 | 
             
                  lhs << rhs
         | 
| 797 | 
            +
                  lhs.line_max = rhs.line_max
         | 
| 797 798 | 
             
                when :const then
         | 
| 798 799 | 
             
                  lhs.sexp_type = :cdecl
         | 
| 799 800 | 
             
                  lhs << rhs
         | 
| @@ -885,12 +886,13 @@ module RubyParserStuff | |
| 885 886 | 
             
                # TODO: need a test with f(&b) to produce block_pass
         | 
| 886 887 | 
             
                # TODO: need a test with f(&b) { } to produce warning
         | 
| 887 888 |  | 
| 888 | 
            -
                if args
         | 
| 889 | 
            +
                if args then
         | 
| 889 890 | 
             
                  if ARG_TYPES[args.sexp_type] then
         | 
| 890 891 | 
             
                    result.concat args.sexp_body
         | 
| 891 892 | 
             
                  else
         | 
| 892 893 | 
             
                    result << args
         | 
| 893 894 | 
             
                  end
         | 
| 895 | 
            +
                  result.line_max = args.line_max
         | 
| 894 896 | 
             
                end
         | 
| 895 897 |  | 
| 896 898 | 
             
                # line = result.grep(Sexp).map(&:line).compact.min
         | 
| @@ -927,7 +929,7 @@ module RubyParserStuff | |
| 927 929 |  | 
| 928 930 | 
             
              def new_class val
         | 
| 929 931 | 
             
                # TODO: get line from class keyword
         | 
| 930 | 
            -
                line, path, superclass,  | 
| 932 | 
            +
                _, line, path, superclass, _, body, (_, line_max) = val
         | 
| 931 933 |  | 
| 932 934 | 
             
                path = path.first if path.instance_of? Array
         | 
| 933 935 |  | 
| @@ -942,6 +944,7 @@ module RubyParserStuff | |
| 942 944 | 
             
                end
         | 
| 943 945 |  | 
| 944 946 | 
             
                result.line = line
         | 
| 947 | 
            +
                result.line_max = line_max
         | 
| 945 948 | 
             
                result.comments = self.comments.pop
         | 
| 946 949 | 
             
                result
         | 
| 947 950 | 
             
              end
         | 
| @@ -970,13 +973,14 @@ module RubyParserStuff | |
| 970 973 | 
             
              end
         | 
| 971 974 |  | 
| 972 975 | 
             
              def new_defn val
         | 
| 973 | 
            -
                _, (name, line), in_def, args, body, _ = val
         | 
| 976 | 
            +
                _, (name, line), in_def, args, body, (_, line_max) = val
         | 
| 974 977 |  | 
| 975 978 | 
             
                body ||= s(:nil).line line
         | 
| 976 979 |  | 
| 977 980 | 
             
                args.line line
         | 
| 978 981 |  | 
| 979 982 | 
             
                result = s(:defn, name.to_sym, args).line line
         | 
| 983 | 
            +
                result.line_max = line_max
         | 
| 980 984 |  | 
| 981 985 | 
             
                if body.sexp_type == :block then
         | 
| 982 986 | 
             
                  result.push(*body.sexp_body)
         | 
| @@ -1033,13 +1037,14 @@ module RubyParserStuff | |
| 1033 1037 | 
             
              end
         | 
| 1034 1038 |  | 
| 1035 1039 | 
             
              def new_defs val
         | 
| 1036 | 
            -
                _, recv, (name, line), in_def, args, body, _ = val
         | 
| 1040 | 
            +
                _, recv, (name, line), in_def, args, body, (_, line_max) = val
         | 
| 1037 1041 |  | 
| 1038 1042 | 
             
                body ||= s(:nil).line line
         | 
| 1039 1043 |  | 
| 1040 1044 | 
             
                args.line line
         | 
| 1041 1045 |  | 
| 1042 1046 | 
             
                result = s(:defs, recv, name.to_sym, args).line line
         | 
| 1047 | 
            +
                result.line_max = line_max
         | 
| 1043 1048 |  | 
| 1044 1049 | 
             
                # TODO: remove_begin
         | 
| 1045 1050 | 
             
                # TODO: reduce_nodes
         | 
| @@ -1204,12 +1209,12 @@ module RubyParserStuff | |
| 1204 1209 | 
             
              end
         | 
| 1205 1210 |  | 
| 1206 1211 | 
             
              def new_module val
         | 
| 1207 | 
            -
                 | 
| 1208 | 
            -
                line, path, body = val[1], val[2], val[4]
         | 
| 1212 | 
            +
                (_, line_min), _, path, _, body, (_, line_max) = val
         | 
| 1209 1213 |  | 
| 1210 1214 | 
             
                path = path.first if path.instance_of? Array
         | 
| 1211 1215 |  | 
| 1212 | 
            -
                result = s(:module, path).line  | 
| 1216 | 
            +
                result = s(:module, path).line line_min
         | 
| 1217 | 
            +
                result.line_max = line_max
         | 
| 1213 1218 |  | 
| 1214 1219 | 
             
                if body then # REFACTOR?
         | 
| 1215 1220 | 
             
                  if body.sexp_type == :block then
         | 
| @@ -1291,9 +1296,10 @@ module RubyParserStuff | |
| 1291 1296 | 
             
              end
         | 
| 1292 1297 |  | 
| 1293 1298 | 
             
              def new_regexp val
         | 
| 1294 | 
            -
                (_, line), node, (options,  | 
| 1299 | 
            +
                (_, line), node, (options, line_max) = val
         | 
| 1295 1300 |  | 
| 1296 1301 | 
             
                node ||= s(:str, "").line line
         | 
| 1302 | 
            +
                node.line_max = line_max
         | 
| 1297 1303 |  | 
| 1298 1304 | 
             
                o, k = 0, nil
         | 
| 1299 1305 | 
             
                options.split(//).uniq.each do |c| # FIX: this has a better home
         |