ruby-next-parser 3.2.2.0 → 3.4.0.0
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
- data/lib/parser/ruby-next/AST_FORMAT.md +16 -6
- data/lib/parser/ruby-next/ast/processor.rb +5 -3
- data/lib/parser/ruby-next/builder.rb +0 -5
- data/lib/parser/ruby-next/meta.rb +5 -3
- data/lib/parser/ruby-next/parser_ext.rb +11 -10
- data/lib/parser/ruby-next/version.rb +1 -1
- data/lib/parser/rubynext.y +111 -161
- metadata +6 -10
- data/lib/parser/ruby-next/lexer-F0.rb +0 -12957
- data/lib/parser/ruby-next/lexer-F1.rb +0 -14968
- data/lib/parser/ruby-next/lexer.rl +0 -2103
- data/lib/parser/rubynext.rb +0 -12743
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 599fb2ab28d4c14213e0f239c8c61f109bb99b250870c14473bd44b7d3bfb24c
         | 
| 4 | 
            +
              data.tar.gz: dfbdb998d62c61daa43db9ed88f50039b12b7c0689d8e39102f4270ef1640559
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e7d9d5aa13d446c071d51b466bf00974eafa328fba0895a3b52d96bcc536d2128d7301e948cf5fcda778dffdd0b21df0ba6711bcef1efa2400b9ebd0cca9cd67
         | 
| 7 | 
            +
              data.tar.gz: f0dfb8fc79df212ac1f1856ac11fd2b57b7530317cec3540fd1cef7d0235a5a1c9386a953f8299adae492688ced8d2792941d1b21e19fa644093e9c3c12f6004
         | 
| @@ -1,14 +1,24 @@ | |
| 1 1 | 
             
            Ruby Next AST format additions
         | 
| 2 2 | 
             
            =======================
         | 
| 3 3 |  | 
| 4 | 
            -
            ###  | 
| 4 | 
            +
            ### Pattern matching non-local variables
         | 
| 5 5 |  | 
| 6 6 | 
             
            Format:
         | 
| 7 7 |  | 
| 8 8 | 
             
            ~~~
         | 
| 9 | 
            -
            ( | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 9 | 
            +
            (in_pattern
         | 
| 10 | 
            +
              (match_as
         | 
| 11 | 
            +
                (int 1),
         | 
| 12 | 
            +
                (match_var (ivar :@a))))
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            "in 1 => @a then true"
         | 
| 15 | 
            +
            ~~~
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            ~~~
         | 
| 18 | 
            +
            (in_pattern
         | 
| 19 | 
            +
              (match_as
         | 
| 20 | 
            +
                (int 1),
         | 
| 21 | 
            +
                (match_var (gvar :$a))))
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            "in 1 => $a then true"
         | 
| 14 24 | 
             
            ~~~
         | 
| @@ -6,11 +6,6 @@ require_relative "meta" | |
| 6 6 | 
             
            module Parser
         | 
| 7 7 | 
             
              # Add RubyNext specific builder methods
         | 
| 8 8 | 
             
              module Builders::Next
         | 
| 9 | 
            -
                def method_ref(receiver, dot_t, selector_t)
         | 
| 10 | 
            -
                  n(:meth_ref, [ receiver, value(selector_t).to_sym ],
         | 
| 11 | 
            -
                      send_map(receiver, dot_t, selector_t, nil, [], nil))
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 9 | 
             
                def match_var(var)
         | 
| 15 10 | 
             
                  return super(var) unless var.is_a?(::Parser::AST::Node)
         | 
| 16 11 |  | 
| @@ -5,9 +5,11 @@ require "parser/meta" | |
| 5 5 | 
             
            module Parser
         | 
| 6 6 | 
             
              # Parser metadata
         | 
| 7 7 | 
             
              module Meta
         | 
| 8 | 
            -
                 | 
| 8 | 
            +
                # This is how you can add new node types to the parser
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                # NEXT_NODE_TYPES = (NODE_TYPES + %i[meth_ref]).to_set.freeze
         | 
| 9 11 |  | 
| 10 | 
            -
                remove_const(:NODE_TYPES)
         | 
| 11 | 
            -
                const_set(:NODE_TYPES, NEXT_NODE_TYPES)
         | 
| 12 | 
            +
                # remove_const(:NODE_TYPES)
         | 
| 13 | 
            +
                # const_set(:NODE_TYPES, NEXT_NODE_TYPES)
         | 
| 12 14 | 
             
              end
         | 
| 13 15 | 
             
            end
         | 
| @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 |  | 
| 4 | 
            -
            if RUBY_ENGINE == 'truffleruby'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            else
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            end
         | 
| 4 | 
            +
            # if RUBY_ENGINE == 'truffleruby'
         | 
| 5 | 
            +
            #   require_relative "lexer-F0"
         | 
| 6 | 
            +
            # else
         | 
| 7 | 
            +
            #   require_relative "lexer-F1"
         | 
| 8 | 
            +
            # end
         | 
| 9 9 | 
             
            require_relative "builder"
         | 
| 10 10 | 
             
            require_relative "ast/processor"
         | 
| 11 11 |  | 
| @@ -18,11 +18,12 @@ module Parser | |
| 18 18 | 
             
                  # Extend builder
         | 
| 19 19 | 
             
                  @builder.singleton_class.prepend(Builders::Next)
         | 
| 20 20 |  | 
| 21 | 
            -
                  #  | 
| 22 | 
            -
                   | 
| 23 | 
            -
                  @lexer | 
| 24 | 
            -
                  @lexer. | 
| 25 | 
            -
                  @lexer. | 
| 21 | 
            +
                  # Here is how to use a custom lexer
         | 
| 22 | 
            +
                  #
         | 
| 23 | 
            +
                  # @lexer = Lexer::Next.new(version)
         | 
| 24 | 
            +
                  # @lexer.diagnostics = @diagnostics
         | 
| 25 | 
            +
                  # @lexer.static_env  = @static_env
         | 
| 26 | 
            +
                  # @lexer.context     = @context
         | 
| 26 27 |  | 
| 27 28 | 
             
                  # Reset the state again
         | 
| 28 29 | 
             
                  reset
         | 
    
        data/lib/parser/rubynext.y
    CHANGED
    
    | @@ -18,7 +18,6 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS | |
| 18 18 | 
             
                  tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
         | 
| 19 19 | 
             
                  tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
         | 
| 20 20 | 
             
                  tRATIONAL tIMAGINARY tLABEL_END tANDDOT tBDOT2 tBDOT3
         | 
| 21 | 
            -
                  tMETHREF
         | 
| 22 21 |  | 
| 23 22 | 
             
            prechigh
         | 
| 24 23 | 
             
              right    tBANG tTILDE tUPLUS
         | 
| @@ -262,7 +261,7 @@ rule | |
| 262 261 | 
             
                                                val[0], val[1], val[2]),
         | 
| 263 262 | 
             
                                              val[3], val[4])
         | 
| 264 263 | 
             
                                }
         | 
| 265 | 
            -
                            | defn_head f_opt_paren_args tEQL  | 
| 264 | 
            +
                            | defn_head f_opt_paren_args tEQL endless_command
         | 
| 266 265 | 
             
                                {
         | 
| 267 266 | 
             
                                  def_t, (name_t, ctx) = val[0]
         | 
| 268 267 | 
             
                                  endless_method_name(name_t)
         | 
| @@ -274,25 +273,7 @@ rule | |
| 274 273 | 
             
                                  @current_arg_stack.pop
         | 
| 275 274 | 
             
                                  @context.in_def = ctx.in_def
         | 
| 276 275 | 
             
                                }
         | 
| 277 | 
            -
                            |  | 
| 278 | 
            -
                                {
         | 
| 279 | 
            -
                                  def_t, (name_t, ctx) = val[0]
         | 
| 280 | 
            -
                                  endless_method_name(name_t)
         | 
| 281 | 
            -
             | 
| 282 | 
            -
                                  rescue_body = @builder.rescue_body(val[4],
         | 
| 283 | 
            -
                                                    nil, nil, nil,
         | 
| 284 | 
            -
                                                    nil, val[5])
         | 
| 285 | 
            -
             | 
| 286 | 
            -
                                  method_body = @builder.begin_body(val[3], [ rescue_body ])
         | 
| 287 | 
            -
             | 
| 288 | 
            -
                                  result = @builder.def_endless_method(def_t, name_t,
         | 
| 289 | 
            -
                                             val[1], val[2], method_body)
         | 
| 290 | 
            -
             | 
| 291 | 
            -
                                  local_pop
         | 
| 292 | 
            -
                                  @current_arg_stack.pop
         | 
| 293 | 
            -
                                  @context.in_def = ctx.in_def
         | 
| 294 | 
            -
                                }
         | 
| 295 | 
            -
                            | defs_head f_opt_paren_args tEQL command
         | 
| 276 | 
            +
                            | defs_head f_opt_paren_args tEQL endless_command
         | 
| 296 277 | 
             
                                {
         | 
| 297 278 | 
             
                                  def_t, recv, dot_t, (name_t, ctx) = val[0]
         | 
| 298 279 | 
             
                                  endless_method_name(name_t)
         | 
| @@ -304,27 +285,23 @@ rule | |
| 304 285 | 
             
                                  @current_arg_stack.pop
         | 
| 305 286 | 
             
                                  @context.in_def = ctx.in_def
         | 
| 306 287 | 
             
                                }
         | 
| 307 | 
            -
                            |  | 
| 288 | 
            +
                            | backref tOP_ASGN command_rhs
         | 
| 308 289 | 
             
                                {
         | 
| 309 | 
            -
                                   | 
| 310 | 
            -
             | 
| 290 | 
            +
                                  @builder.op_assign(val[0], val[1], val[2])
         | 
| 291 | 
            +
                                }
         | 
| 311 292 |  | 
| 312 | 
            -
             | 
| 293 | 
            +
             endless_command: command
         | 
| 294 | 
            +
                            | endless_command kRESCUE_MOD arg
         | 
| 295 | 
            +
                                {
         | 
| 296 | 
            +
                                  rescue_body = @builder.rescue_body(val[1],
         | 
| 313 297 | 
             
                                                    nil, nil, nil,
         | 
| 314 | 
            -
                                                    nil, val[ | 
| 315 | 
            -
             | 
| 316 | 
            -
                                  method_body = @builder.begin_body(val[3], [ rescue_body ])
         | 
| 317 | 
            -
             | 
| 318 | 
            -
                                  result = @builder.def_endless_singleton(def_t, recv, dot_t, name_t,
         | 
| 319 | 
            -
                                             val[1], val[2], method_body)
         | 
| 298 | 
            +
                                                    nil, val[2])
         | 
| 320 299 |  | 
| 321 | 
            -
                                   | 
| 322 | 
            -
                                  @current_arg_stack.pop
         | 
| 323 | 
            -
                                  @context.in_def = ctx.in_def
         | 
| 300 | 
            +
                                  result = @builder.begin_body(val[0], [ rescue_body ])
         | 
| 324 301 | 
             
                                }
         | 
| 325 | 
            -
                            |  | 
| 302 | 
            +
                            | kNOT opt_nl endless_command
         | 
| 326 303 | 
             
                                {
         | 
| 327 | 
            -
                                  @builder. | 
| 304 | 
            +
                                  result = @builder.not_op(val[0], nil, val[2], nil)
         | 
| 328 305 | 
             
                                }
         | 
| 329 306 |  | 
| 330 307 | 
             
                 command_rhs: command_call =tOP_ASGN
         | 
| @@ -355,39 +332,19 @@ rule | |
| 355 332 | 
             
                                {
         | 
| 356 333 | 
             
                                  result = @builder.not_op(val[0], nil, val[1], nil)
         | 
| 357 334 | 
             
                                }
         | 
| 358 | 
            -
                            | arg tASSOC
         | 
| 359 | 
            -
                                {
         | 
| 360 | 
            -
                                  @lexer.state = :expr_beg
         | 
| 361 | 
            -
                                  @lexer.command_start = false
         | 
| 362 | 
            -
                                  @pattern_variables.push
         | 
| 363 | 
            -
                                  @pattern_hash_keys.push
         | 
| 364 | 
            -
             | 
| 365 | 
            -
                                  result = @context.in_kwarg
         | 
| 366 | 
            -
                                  @context.in_kwarg = true
         | 
| 367 | 
            -
                                }
         | 
| 368 | 
            -
                              p_top_expr_body
         | 
| 335 | 
            +
                            | arg tASSOC p_in_kwarg p_pvtbl p_pktbl p_top_expr_body
         | 
| 369 336 | 
             
                                {
         | 
| 370 337 | 
             
                                  @pattern_variables.pop
         | 
| 371 338 | 
             
                                  @pattern_hash_keys.pop
         | 
| 372 339 | 
             
                                  @context.in_kwarg = val[2]
         | 
| 373 | 
            -
                                  result = @builder.match_pattern(val[0], val[1], val[ | 
| 340 | 
            +
                                  result = @builder.match_pattern(val[0], val[1], val[5])
         | 
| 374 341 | 
             
                                }
         | 
| 375 | 
            -
                            | arg kIN
         | 
| 376 | 
            -
                                {
         | 
| 377 | 
            -
                                  @lexer.state = :expr_beg
         | 
| 378 | 
            -
                                  @lexer.command_start = false
         | 
| 379 | 
            -
                                  @pattern_variables.push
         | 
| 380 | 
            -
                                  @pattern_hash_keys.push
         | 
| 381 | 
            -
             | 
| 382 | 
            -
                                  result = @context.in_kwarg
         | 
| 383 | 
            -
                                  @context.in_kwarg = true
         | 
| 384 | 
            -
                                }
         | 
| 385 | 
            -
                              p_top_expr_body
         | 
| 342 | 
            +
                            | arg kIN p_in_kwarg p_pvtbl p_pktbl p_top_expr_body
         | 
| 386 343 | 
             
                                {
         | 
| 387 344 | 
             
                                  @pattern_variables.pop
         | 
| 388 345 | 
             
                                  @pattern_hash_keys.pop
         | 
| 389 346 | 
             
                                  @context.in_kwarg = val[2]
         | 
| 390 | 
            -
                                  result = @builder.match_pattern_p(val[0], val[1], val[ | 
| 347 | 
            +
                                  result = @builder.match_pattern_p(val[0], val[1], val[5])
         | 
| 391 348 | 
             
                                }
         | 
| 392 349 | 
             
                            | arg =tLBRACE_ARG
         | 
| 393 350 |  | 
| @@ -409,6 +366,7 @@ rule | |
| 409 366 |  | 
| 410 367 | 
             
                                  result = [ val[0], @context.dup ]
         | 
| 411 368 | 
             
                                  @context.in_def = true
         | 
| 369 | 
            +
                                  @context.cant_return = false
         | 
| 412 370 | 
             
                                }
         | 
| 413 371 |  | 
| 414 372 | 
             
                   defn_head: k_def def_name
         | 
| @@ -492,6 +450,14 @@ rule | |
| 492 450 | 
             
                                  result      = @builder.block(method_call,
         | 
| 493 451 | 
             
                                                  begin_t, args, body, end_t)
         | 
| 494 452 | 
             
                                }
         | 
| 453 | 
            +
                            | primary_value tCOLON2 tCONSTANT tLCURLY brace_body tRCURLY
         | 
| 454 | 
            +
                                {
         | 
| 455 | 
            +
                                  method_call = @builder.call_method(val[0], val[1], val[2],
         | 
| 456 | 
            +
                                                    nil, [], nil)
         | 
| 457 | 
            +
             | 
| 458 | 
            +
                                  args, body = val[4]
         | 
| 459 | 
            +
                                  result = @builder.block(method_call, val[3], args, body, val[5])
         | 
| 460 | 
            +
                                }
         | 
| 495 461 | 
             
                            | kSUPER command_args
         | 
| 496 462 | 
             
                                {
         | 
| 497 463 | 
             
                                  result = @builder.keyword_cmd(:super, val[0],
         | 
| @@ -926,13 +892,9 @@ rule | |
| 926 892 | 
             
                                {
         | 
| 927 893 | 
             
                                  result = @builder.logical_op(:or, val[0], val[1], val[2])
         | 
| 928 894 | 
             
                                }
         | 
| 929 | 
            -
                            | kDEFINED opt_nl
         | 
| 930 | 
            -
                                {
         | 
| 931 | 
            -
                                  @context.in_defined = true
         | 
| 932 | 
            -
                                }
         | 
| 933 | 
            -
                              arg
         | 
| 895 | 
            +
                            | kDEFINED opt_nl begin_defined arg
         | 
| 934 896 | 
             
                                {
         | 
| 935 | 
            -
                                  @context.in_defined =  | 
| 897 | 
            +
                                  @context.in_defined = val[2].in_defined
         | 
| 936 898 | 
             
                                  result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[3] ], nil)
         | 
| 937 899 | 
             
                                }
         | 
| 938 900 | 
             
                            | arg tEH arg opt_nl tCOLON arg
         | 
| @@ -940,7 +902,7 @@ rule | |
| 940 902 | 
             
                                  result = @builder.ternary(val[0], val[1],
         | 
| 941 903 | 
             
                                                            val[2], val[4], val[5])
         | 
| 942 904 | 
             
                                }
         | 
| 943 | 
            -
                            | defn_head f_opt_paren_args tEQL  | 
| 905 | 
            +
                            | defn_head f_opt_paren_args tEQL endless_arg
         | 
| 944 906 | 
             
                                {
         | 
| 945 907 | 
             
                                  def_t, (name_t, ctx) = val[0]
         | 
| 946 908 | 
             
                                  endless_method_name(name_t)
         | 
| @@ -952,25 +914,7 @@ rule | |
| 952 914 | 
             
                                  @current_arg_stack.pop
         | 
| 953 915 | 
             
                                  @context.in_def = ctx.in_def
         | 
| 954 916 | 
             
                                }
         | 
| 955 | 
            -
                            |  | 
| 956 | 
            -
                                {
         | 
| 957 | 
            -
                                  def_t, (name_t, ctx) = val[0]
         | 
| 958 | 
            -
                                  endless_method_name(name_t)
         | 
| 959 | 
            -
             | 
| 960 | 
            -
                                  rescue_body = @builder.rescue_body(val[4],
         | 
| 961 | 
            -
                                                    nil, nil, nil,
         | 
| 962 | 
            -
                                                    nil, val[5])
         | 
| 963 | 
            -
             | 
| 964 | 
            -
                                  method_body = @builder.begin_body(val[3], [ rescue_body ])
         | 
| 965 | 
            -
             | 
| 966 | 
            -
                                  result = @builder.def_endless_method(def_t, name_t,
         | 
| 967 | 
            -
                                             val[1], val[2], method_body)
         | 
| 968 | 
            -
             | 
| 969 | 
            -
                                  local_pop
         | 
| 970 | 
            -
                                  @current_arg_stack.pop
         | 
| 971 | 
            -
                                  @context.in_def = ctx.in_def
         | 
| 972 | 
            -
                                }
         | 
| 973 | 
            -
                            | defs_head f_opt_paren_args tEQL arg
         | 
| 917 | 
            +
                            | defs_head f_opt_paren_args tEQL endless_arg
         | 
| 974 918 | 
             
                                {
         | 
| 975 919 | 
             
                                  def_t, recv, dot_t, (name_t, ctx) = val[0]
         | 
| 976 920 | 
             
                                  endless_method_name(name_t)
         | 
| @@ -982,25 +926,21 @@ rule | |
| 982 926 | 
             
                                  @current_arg_stack.pop
         | 
| 983 927 | 
             
                                  @context.in_def = ctx.in_def
         | 
| 984 928 | 
             
                                }
         | 
| 985 | 
            -
                            |  | 
| 986 | 
            -
                                {
         | 
| 987 | 
            -
                                  def_t, recv, dot_t, (name_t, ctx) = val[0]
         | 
| 988 | 
            -
                                  endless_method_name(name_t)
         | 
| 929 | 
            +
                            | primary
         | 
| 989 930 |  | 
| 990 | 
            -
             | 
| 931 | 
            +
                 endless_arg: arg=kRESCUE_MOD
         | 
| 932 | 
            +
                            | endless_arg kRESCUE_MOD arg
         | 
| 933 | 
            +
                                {
         | 
| 934 | 
            +
                                  rescue_body = @builder.rescue_body(val[1],
         | 
| 991 935 | 
             
                                                    nil, nil, nil,
         | 
| 992 | 
            -
                                                    nil, val[ | 
| 993 | 
            -
             | 
| 994 | 
            -
                                  method_body = @builder.begin_body(val[3], [ rescue_body ])
         | 
| 995 | 
            -
             | 
| 996 | 
            -
                                  result = @builder.def_endless_singleton(def_t, recv, dot_t, name_t,
         | 
| 997 | 
            -
                                             val[1], val[2], method_body)
         | 
| 936 | 
            +
                                                    nil, val[2])
         | 
| 998 937 |  | 
| 999 | 
            -
                                   | 
| 1000 | 
            -
             | 
| 1001 | 
            -
             | 
| 938 | 
            +
                                  result = @builder.begin_body(val[0], [ rescue_body ])
         | 
| 939 | 
            +
                                }
         | 
| 940 | 
            +
                            | kNOT opt_nl endless_arg
         | 
| 941 | 
            +
                                {
         | 
| 942 | 
            +
                                  result = @builder.not_op(val[0], nil, val[2], nil)
         | 
| 1002 943 | 
             
                                }
         | 
| 1003 | 
            -
                            | primary
         | 
| 1004 944 |  | 
| 1005 945 | 
             
                       relop: tGT | tLT | tGEQ | tLEQ
         | 
| 1006 946 |  | 
| @@ -1013,6 +953,11 @@ rule | |
| 1013 953 | 
             
                                  result = @builder.binary_op(val[0], val[1], val[2])
         | 
| 1014 954 | 
             
                                }
         | 
| 1015 955 |  | 
| 956 | 
            +
               begin_defined: none
         | 
| 957 | 
            +
                                {
         | 
| 958 | 
            +
                                  result = @context.dup
         | 
| 959 | 
            +
                                }
         | 
| 960 | 
            +
             | 
| 1016 961 | 
             
                   arg_value: arg
         | 
| 1017 962 |  | 
| 1018 963 | 
             
                   aref_args: none
         | 
| @@ -1156,6 +1101,11 @@ rule | |
| 1156 1101 | 
             
                                    diagnostic :error, :no_anonymous_blockarg, nil, val[0]
         | 
| 1157 1102 | 
             
                                  end
         | 
| 1158 1103 |  | 
| 1104 | 
            +
                                  if @context.in_dynamic_block? && context.in_def &&
         | 
| 1105 | 
            +
                                    @static_env.declared_anonymous_blockarg_in_current_scpe? && @static_env.parent_has_anonymous_blockarg?
         | 
| 1106 | 
            +
                                    diagnostic :error, :ambiguous_anonymous_blockarg, nil, val[0]
         | 
| 1107 | 
            +
                                  end
         | 
| 1108 | 
            +
             | 
| 1159 1109 | 
             
                                  result = @builder.block_pass(val[0], nil)
         | 
| 1160 1110 | 
             
                                }
         | 
| 1161 1111 |  | 
| @@ -1172,7 +1122,17 @@ rule | |
| 1172 1122 | 
             
                                {
         | 
| 1173 1123 | 
             
                                  result = [ val[0] ]
         | 
| 1174 1124 | 
             
                                }
         | 
| 1175 | 
            -
                            |  | 
| 1125 | 
            +
                            | arg_splat
         | 
| 1126 | 
            +
                            | args tCOMMA arg_value
         | 
| 1127 | 
            +
                                {
         | 
| 1128 | 
            +
                                  result = val[0] << val[2]
         | 
| 1129 | 
            +
                                }
         | 
| 1130 | 
            +
                            | args tCOMMA arg_splat
         | 
| 1131 | 
            +
                                {
         | 
| 1132 | 
            +
                                  result = val[0].concat(val[2])
         | 
| 1133 | 
            +
                                }
         | 
| 1134 | 
            +
             | 
| 1135 | 
            +
                   arg_splat: tSTAR arg_value
         | 
| 1176 1136 | 
             
                                {
         | 
| 1177 1137 | 
             
                                  result = [ @builder.splat(val[0], val[1]) ]
         | 
| 1178 1138 | 
             
                                }
         | 
| @@ -1182,23 +1142,12 @@ rule | |
| 1182 1142 | 
             
                                    diagnostic :error, :no_anonymous_restarg, nil, val[0]
         | 
| 1183 1143 | 
             
                                  end
         | 
| 1184 1144 |  | 
| 1185 | 
            -
                                   | 
| 1186 | 
            -
             | 
| 1187 | 
            -
             | 
| 1188 | 
            -
                                {
         | 
| 1189 | 
            -
                                  result = val[0] << val[2]
         | 
| 1190 | 
            -
                                }
         | 
| 1191 | 
            -
                            | args tCOMMA tSTAR arg_value
         | 
| 1192 | 
            -
                                {
         | 
| 1193 | 
            -
                                  result = val[0] << @builder.splat(val[2], val[3])
         | 
| 1194 | 
            -
                                }
         | 
| 1195 | 
            -
                            | args tCOMMA tSTAR
         | 
| 1196 | 
            -
                                {
         | 
| 1197 | 
            -
                                  if !@static_env.declared_anonymous_restarg?
         | 
| 1198 | 
            -
                                    diagnostic :error, :no_anonymous_restarg, nil, val[2]
         | 
| 1145 | 
            +
                                  if @context.in_dynamic_block? && context.in_def &&
         | 
| 1146 | 
            +
                                    @static_env.declared_anonymous_restarg_in_current_scope? && @static_env.parent_has_anonymous_restarg?
         | 
| 1147 | 
            +
                                    diagnostic :error, :ambiguous_anonymous_restarg, nil, val[0]
         | 
| 1199 1148 | 
             
                                  end
         | 
| 1200 1149 |  | 
| 1201 | 
            -
                                  result =  | 
| 1150 | 
            +
                                  result = [ @builder.forwarded_restarg(val[0]) ]
         | 
| 1202 1151 | 
             
                                }
         | 
| 1203 1152 |  | 
| 1204 1153 | 
             
                    mrhs_arg: mrhs
         | 
| @@ -1244,22 +1193,14 @@ rule | |
| 1244 1193 |  | 
| 1245 1194 | 
             
                                  result = @builder.begin_keyword(val[0], val[2], val[3])
         | 
| 1246 1195 | 
             
                                }
         | 
| 1247 | 
            -
                            | tLPAREN_ARG  | 
| 1196 | 
            +
                            | tLPAREN_ARG compstmt
         | 
| 1248 1197 | 
             
                                {
         | 
| 1249 1198 | 
             
                                  @lexer.state = :expr_endarg
         | 
| 1250 1199 | 
             
                                }
         | 
| 1251 | 
            -
                                 | 
| 1200 | 
            +
                                tRPAREN
         | 
| 1252 1201 | 
             
                                {
         | 
| 1253 1202 | 
             
                                  result = @builder.begin(val[0], val[1], val[3])
         | 
| 1254 1203 | 
             
                                }
         | 
| 1255 | 
            -
                            | tLPAREN_ARG
         | 
| 1256 | 
            -
                                {
         | 
| 1257 | 
            -
                                  @lexer.state = :expr_endarg
         | 
| 1258 | 
            -
                                }
         | 
| 1259 | 
            -
                                opt_nl tRPAREN
         | 
| 1260 | 
            -
                                {
         | 
| 1261 | 
            -
                                  result = @builder.begin(val[0], nil, val[3])
         | 
| 1262 | 
            -
                                }
         | 
| 1263 1204 | 
             
                            | tLPAREN compstmt tRPAREN
         | 
| 1264 1205 | 
             
                                {
         | 
| 1265 1206 | 
             
                                  result = @builder.begin(val[0], val[1], val[2])
         | 
| @@ -1296,13 +1237,9 @@ rule | |
| 1296 1237 | 
             
                                {
         | 
| 1297 1238 | 
             
                                  result = @builder.keyword_cmd(:yield, val[0])
         | 
| 1298 1239 | 
             
                                }
         | 
| 1299 | 
            -
                            | kDEFINED opt_nl tLPAREN2
         | 
| 1300 | 
            -
                                {
         | 
| 1301 | 
            -
                                  @context.in_defined = true
         | 
| 1302 | 
            -
                                }
         | 
| 1303 | 
            -
                              expr rparen
         | 
| 1240 | 
            +
                            | kDEFINED opt_nl tLPAREN2 begin_defined expr rparen
         | 
| 1304 1241 | 
             
                                {
         | 
| 1305 | 
            -
                                  @context.in_defined =  | 
| 1242 | 
            +
                                  @context.in_defined = val[3].in_defined
         | 
| 1306 1243 | 
             
                                  result = @builder.keyword_cmd(:defined?, val[0],
         | 
| 1307 1244 | 
             
                                                                val[2], [ val[4] ], val[5])
         | 
| 1308 1245 | 
             
                                }
         | 
| @@ -1383,6 +1320,7 @@ rule | |
| 1383 1320 | 
             
                            | k_class cpath superclass
         | 
| 1384 1321 | 
             
                                {
         | 
| 1385 1322 | 
             
                                  @context.in_class = true
         | 
| 1323 | 
            +
                                  @context.cant_return = true
         | 
| 1386 1324 | 
             
                                  local_push
         | 
| 1387 1325 | 
             
                                }
         | 
| 1388 1326 | 
             
                                bodystmt kEND
         | 
| @@ -1398,11 +1336,13 @@ rule | |
| 1398 1336 |  | 
| 1399 1337 | 
             
                                  local_pop
         | 
| 1400 1338 | 
             
                                  @context.in_class = ctx.in_class
         | 
| 1339 | 
            +
                                  @context.cant_return = ctx.cant_return
         | 
| 1401 1340 | 
             
                                }
         | 
| 1402 | 
            -
                            | k_class tLSHFT  | 
| 1341 | 
            +
                            | k_class tLSHFT expr_value term
         | 
| 1403 1342 | 
             
                                {
         | 
| 1404 1343 | 
             
                                  @context.in_def = false
         | 
| 1405 1344 | 
             
                                  @context.in_class = false
         | 
| 1345 | 
            +
                                  @context.cant_return = true
         | 
| 1406 1346 | 
             
                                  local_push
         | 
| 1407 1347 | 
             
                                }
         | 
| 1408 1348 | 
             
                                bodystmt kEND
         | 
| @@ -1414,10 +1354,12 @@ rule | |
| 1414 1354 | 
             
                                  local_pop
         | 
| 1415 1355 | 
             
                                  @context.in_def = ctx.in_def
         | 
| 1416 1356 | 
             
                                  @context.in_class = ctx.in_class
         | 
| 1357 | 
            +
                                  @context.cant_return = ctx.cant_return
         | 
| 1417 1358 | 
             
                                }
         | 
| 1418 1359 | 
             
                            | k_module cpath
         | 
| 1419 1360 | 
             
                                {
         | 
| 1420 1361 | 
             
                                  @context.in_class = true
         | 
| 1362 | 
            +
                                  @context.cant_return = true
         | 
| 1421 1363 | 
             
                                  local_push
         | 
| 1422 1364 | 
             
                                }
         | 
| 1423 1365 | 
             
                                bodystmt kEND
         | 
| @@ -1431,6 +1373,7 @@ rule | |
| 1431 1373 |  | 
| 1432 1374 | 
             
                                  local_pop
         | 
| 1433 1375 | 
             
                                  @context.in_class = ctx.in_class
         | 
| 1376 | 
            +
                                  @context.cant_return = ctx.cant_return
         | 
| 1434 1377 | 
             
                                }
         | 
| 1435 1378 | 
             
                            | defn_head f_arglist bodystmt kEND
         | 
| 1436 1379 | 
             
                                {
         | 
| @@ -1468,10 +1411,6 @@ rule | |
| 1468 1411 | 
             
                                {
         | 
| 1469 1412 | 
             
                                  result = @builder.keyword_cmd(:retry, val[0])
         | 
| 1470 1413 | 
             
                                }
         | 
| 1471 | 
            -
                            | primary_value tMETHREF operation2
         | 
| 1472 | 
            -
                                {
         | 
| 1473 | 
            -
                                  result = @builder.method_ref(val[0], val[1], val[2])
         | 
| 1474 | 
            -
                                }
         | 
| 1475 1414 |  | 
| 1476 1415 | 
             
               primary_value: primary
         | 
| 1477 1416 |  | 
| @@ -1493,7 +1432,7 @@ rule | |
| 1493 1432 |  | 
| 1494 1433 | 
             
                    k_return: kRETURN
         | 
| 1495 1434 | 
             
                                {
         | 
| 1496 | 
            -
                                  if @context. | 
| 1435 | 
            +
                                  if @context.cant_return && !(context.in_block || context.in_lambda)
         | 
| 1497 1436 | 
             
                                    diagnostic :error, :invalid_return, nil, val[0]
         | 
| 1498 1437 | 
             
                                  end
         | 
| 1499 1438 | 
             
                                }
         | 
| @@ -1970,17 +1909,26 @@ opt_block_args_tail: | |
| 1970 1909 | 
             
                                }
         | 
| 1971 1910 | 
             
                            | case_body
         | 
| 1972 1911 |  | 
| 1973 | 
            -
             | 
| 1912 | 
            +
                     p_pvtbl: none
         | 
| 1974 1913 | 
             
                                {
         | 
| 1975 | 
            -
                                  @lexer.state = :expr_beg
         | 
| 1976 | 
            -
                                  @lexer.command_start = false
         | 
| 1977 1914 | 
             
                                  @pattern_variables.push
         | 
| 1915 | 
            +
                                }
         | 
| 1916 | 
            +
             | 
| 1917 | 
            +
                     p_pktbl: none
         | 
| 1918 | 
            +
                                {
         | 
| 1978 1919 | 
             
                                  @pattern_hash_keys.push
         | 
| 1920 | 
            +
                                }
         | 
| 1979 1921 |  | 
| 1922 | 
            +
                  p_in_kwarg: none
         | 
| 1923 | 
            +
                                {
         | 
| 1980 1924 | 
             
                                  result = @context.in_kwarg
         | 
| 1925 | 
            +
             | 
| 1926 | 
            +
                                  @lexer.state = :expr_beg
         | 
| 1927 | 
            +
                                  @lexer.command_start = false
         | 
| 1981 1928 | 
             
                                  @context.in_kwarg = true
         | 
| 1982 1929 | 
             
                                }
         | 
| 1983 | 
            -
             | 
| 1930 | 
            +
             | 
| 1931 | 
            +
                 p_case_body: kIN p_in_kwarg p_pvtbl p_pktbl p_top_expr then
         | 
| 1984 1932 | 
             
                                {
         | 
| 1985 1933 | 
             
                                  @pattern_variables.pop
         | 
| 1986 1934 | 
             
                                  @pattern_hash_keys.pop
         | 
| @@ -1988,8 +1936,8 @@ opt_block_args_tail: | |
| 1988 1936 | 
             
                                }
         | 
| 1989 1937 | 
             
                              compstmt p_cases
         | 
| 1990 1938 | 
             
                                {
         | 
| 1991 | 
            -
                                  result = [ @builder.in_pattern(val[0], *val[ | 
| 1992 | 
            -
                                             *val[ | 
| 1939 | 
            +
                                  result = [ @builder.in_pattern(val[0], *val[4], val[5], val[7]),
         | 
| 1940 | 
            +
                                             *val[8] ]
         | 
| 1993 1941 | 
             
                                }
         | 
| 1994 1942 |  | 
| 1995 1943 | 
             
                     p_cases: opt_else
         | 
| @@ -2465,6 +2413,9 @@ opt_block_args_tail: | |
| 2465 2413 | 
             
                                  result = @builder.regexp_compose(val[0], val[1], val[2], opts)
         | 
| 2466 2414 | 
             
                                }
         | 
| 2467 2415 |  | 
| 2416 | 
            +
                   words_sep: tSPACE
         | 
| 2417 | 
            +
                            | words_sep tSPACE
         | 
| 2418 | 
            +
             | 
| 2468 2419 | 
             
                       words: tWORDS_BEG word_list tSTRING_END
         | 
| 2469 2420 | 
             
                                {
         | 
| 2470 2421 | 
             
                                  result = @builder.words_compose(val[0], val[1], val[2])
         | 
| @@ -2474,7 +2425,7 @@ opt_block_args_tail: | |
| 2474 2425 | 
             
                                {
         | 
| 2475 2426 | 
             
                                  result = []
         | 
| 2476 2427 | 
             
                                }
         | 
| 2477 | 
            -
                            | word_list word  | 
| 2428 | 
            +
                            | word_list word words_sep
         | 
| 2478 2429 | 
             
                                {
         | 
| 2479 2430 | 
             
                                  result = val[0] << @builder.word(val[1])
         | 
| 2480 2431 | 
             
                                }
         | 
| @@ -2497,7 +2448,7 @@ opt_block_args_tail: | |
| 2497 2448 | 
             
                                {
         | 
| 2498 2449 | 
             
                                  result = []
         | 
| 2499 2450 | 
             
                                }
         | 
| 2500 | 
            -
                            | symbol_list word  | 
| 2451 | 
            +
                            | symbol_list word words_sep
         | 
| 2501 2452 | 
             
                                {
         | 
| 2502 2453 | 
             
                                  result = val[0] << @builder.word(val[1])
         | 
| 2503 2454 | 
             
                                }
         | 
| @@ -2516,7 +2467,7 @@ opt_block_args_tail: | |
| 2516 2467 | 
             
                                {
         | 
| 2517 2468 | 
             
                                  result = []
         | 
| 2518 2469 | 
             
                                }
         | 
| 2519 | 
            -
                            | qword_list tSTRING_CONTENT  | 
| 2470 | 
            +
                            | qword_list tSTRING_CONTENT words_sep
         | 
| 2520 2471 | 
             
                                {
         | 
| 2521 2472 | 
             
                                  result = val[0] << @builder.string_internal(val[1])
         | 
| 2522 2473 | 
             
                                }
         | 
| @@ -2525,7 +2476,7 @@ opt_block_args_tail: | |
| 2525 2476 | 
             
                                {
         | 
| 2526 2477 | 
             
                                  result = []
         | 
| 2527 2478 | 
             
                                }
         | 
| 2528 | 
            -
                            | qsym_list tSTRING_CONTENT  | 
| 2479 | 
            +
                            | qsym_list tSTRING_CONTENT words_sep
         | 
| 2529 2480 | 
             
                                {
         | 
| 2530 2481 | 
             
                                  result = val[0] << @builder.symbol_internal(val[1])
         | 
| 2531 2482 | 
             
                                }
         | 
| @@ -2570,7 +2521,7 @@ regexp_contents: # nothing | |
| 2570 2521 | 
             
                                  @lexer.cmdarg.push(false)
         | 
| 2571 2522 | 
             
                                  @lexer.cond.push(false)
         | 
| 2572 2523 | 
             
                                }
         | 
| 2573 | 
            -
                                compstmt  | 
| 2524 | 
            +
                                compstmt string_dend
         | 
| 2574 2525 | 
             
                                {
         | 
| 2575 2526 | 
             
                                  @lexer.cmdarg.pop
         | 
| 2576 2527 | 
             
                                  @lexer.cond.pop
         | 
| @@ -2578,17 +2529,11 @@ regexp_contents: # nothing | |
| 2578 2529 | 
             
                                  result = @builder.begin(val[0], val[2], val[3])
         | 
| 2579 2530 | 
             
                                }
         | 
| 2580 2531 |  | 
| 2581 | 
            -
                  | 
| 2582 | 
            -
             | 
| 2583 | 
            -
             | 
| 2584 | 
            -
                                }
         | 
| 2585 | 
            -
                            | tIVAR
         | 
| 2586 | 
            -
                                {
         | 
| 2587 | 
            -
                                  result = @builder.ivar(val[0])
         | 
| 2588 | 
            -
                                }
         | 
| 2589 | 
            -
                            | tCVAR
         | 
| 2532 | 
            +
                 string_dend: tSTRING_DEND
         | 
| 2533 | 
            +
             | 
| 2534 | 
            +
                 string_dvar: nonlocal_var
         | 
| 2590 2535 | 
             
                                {
         | 
| 2591 | 
            -
                                  result = @builder. | 
| 2536 | 
            +
                                  result = @builder.accessible(val[0])
         | 
| 2592 2537 | 
             
                                }
         | 
| 2593 2538 | 
             
                            | backref
         | 
| 2594 2539 |  | 
| @@ -3134,6 +3079,11 @@ f_opt_paren_args: f_paren_args | |
| 3134 3079 | 
             
                                    diagnostic :error, :no_anonymous_kwrestarg, nil, val[0]
         | 
| 3135 3080 | 
             
                                  end
         | 
| 3136 3081 |  | 
| 3082 | 
            +
                                  if @context.in_dynamic_block? && context.in_def &&
         | 
| 3083 | 
            +
                                    @static_env.declared_anonymous_kwrestarg_in_current_scope? && @static_env.parent_has_anonymous_kwrestarg?
         | 
| 3084 | 
            +
                                    diagnostic :error, :ambiguous_anonymous_kwrestarg, nil, val[0]
         | 
| 3085 | 
            +
                                  end
         | 
| 3086 | 
            +
             | 
| 3137 3087 | 
             
                                  result = @builder.forwarded_kwrestarg(val[0])
         | 
| 3138 3088 | 
             
                                }
         | 
| 3139 3089 |  | 
| @@ -3190,7 +3140,7 @@ require 'parser/ruby-next/parser_ext' | |
| 3190 3140 | 
             
            prepend Parser::NextExt
         | 
| 3191 3141 |  | 
| 3192 3142 | 
             
              def version
         | 
| 3193 | 
            -
                 | 
| 3143 | 
            +
                34
         | 
| 3194 3144 | 
             
              end
         | 
| 3195 3145 |  | 
| 3196 3146 | 
             
              def default_encoding
         |