parser 2.5.1.0 → 2.5.1.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
 - data/CHANGELOG.md +13 -1
 - data/README.md +1 -1
 - data/doc/AST_FORMAT.md +19 -2
 - data/lib/parser/ast/processor.rb +1 -0
 - data/lib/parser/builders/default.rb +12 -2
 - data/lib/parser/lexer.rl +2 -2
 - data/lib/parser/lexer/stack_state.rb +4 -0
 - data/lib/parser/ruby24.y +14 -1
 - data/lib/parser/ruby25.y +15 -2
 - data/lib/parser/ruby26.y +22 -1
 - data/lib/parser/source/buffer.rb +1 -1
 - data/lib/parser/source/comment.rb +4 -4
 - data/lib/parser/source/comment/associator.rb +3 -3
 - data/lib/parser/source/map.rb +1 -1
 - data/lib/parser/source/range.rb +1 -1
 - data/lib/parser/source/tree_rewriter.rb +2 -2
 - data/lib/parser/version.rb +1 -1
 - data/test/parse_helper.rb +1 -1
 - data/test/test_parser.rb +62 -2
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 74690ed0b42a0adf60b87ac491252301383d408f49c94b3ca57569f731bba610
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: bcfab73accb005126ca982eba28ceff93539f4f2b84523e1f31fe9d11f898808
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4b84846a1eff219eb607276d2b21a3e9c3e08ffc527aa5eb221ae73712e3b3d461ede2b9fae72a995db4dc761d3dc438fd81f2b278bdf577a39a08b04ceb2364
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3a0febdb064269e6e0ef29e84d86f75c2b9b7ef2ab004e0fe25734d7a58ae947a2507eab90926c28a86cf9fb761c5882205633d25b37639c4807b4ee9bac9e7e
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,9 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Changelog
         
     | 
| 
       2 
2 
     | 
    
         
             
            =========
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            Not released (2018- 
     | 
| 
      
 4 
     | 
    
         
            +
            Not released (2018-07-10)
         
     | 
| 
       5 
5 
     | 
    
         
             
            -------------------------
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
            Features implemented:
         
     | 
| 
      
 8 
     | 
    
         
            +
             * ruby26.y: Endless ranges support. (Ilya Bylich)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            Bugs fixed:
         
     | 
| 
      
 11 
     | 
    
         
            +
             * lexer.rl: Fix parsing of 'm = -> *args do end'. (Ilya Bylich)
         
     | 
| 
      
 12 
     | 
    
         
            +
             * AST::Processor: Properly recurse into "kwsplat" nodes (Nelson Elhage)
         
     | 
| 
      
 13 
     | 
    
         
            +
             * ruby24, ruby25, ruby26: Fix cmdargs after command_args followed by tLBRACE_ARG. This commit tracks upstream commit ruby/ruby@f168dbd. (Ilya Bylich)
         
     | 
| 
      
 14 
     | 
    
         
            +
             * lexer.rl: Fix parsing of `let (:a) { m do; end }`. (Ilya Bylich)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            v2.5.1.0 (2018-04-12)
         
     | 
| 
      
 17 
     | 
    
         
            +
            ---------------------
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       7 
19 
     | 
    
         
             
            API modifications:
         
     | 
| 
       8 
20 
     | 
    
         
             
             * Parser::Current: bump latest 2.2 branch to 2.2.10. (Ilya Bylich)
         
     | 
| 
       9 
21 
     | 
    
         | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -217,7 +217,7 @@ at some point. 
     | 
|
| 
       217 
217 
     | 
    
         
             
            Sometimes it is necessary to modify the format of AST nodes that are already being emitted
         
     | 
| 
       218 
218 
     | 
    
         
             
            in a way that would break existing applications. To avoid such breakage, applications
         
     | 
| 
       219 
219 
     | 
    
         
             
            must opt-in to these modifications; without explicit opt-in, Parser will continue to emit
         
     | 
| 
       220 
     | 
    
         
            -
            the old AST node format. The most recent set of opt-ins is  
     | 
| 
      
 220 
     | 
    
         
            +
            the old AST node format. The most recent set of opt-ins is specified in
         
     | 
| 
       221 
221 
     | 
    
         
             
            the [usage section](#usage) of this README.
         
     | 
| 
       222 
222 
     | 
    
         | 
| 
       223 
223 
     | 
    
         
             
            ## Compatibility with Ruby MRI
         
     | 
    
        data/doc/AST_FORMAT.md
    CHANGED
    
    | 
         @@ -322,6 +322,23 @@ Format: 
     | 
|
| 
       322 
322 
     | 
    
         
             
             ~~~~~ expression
         
     | 
| 
       323 
323 
     | 
    
         
             
            ~~~
         
     | 
| 
       324 
324 
     | 
    
         | 
| 
      
 325 
     | 
    
         
            +
             
     | 
| 
      
 326 
     | 
    
         
            +
            ### Endless (2.6)
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
            Format:
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
            ~~~
         
     | 
| 
      
 331 
     | 
    
         
            +
            (irange (int 1) nil)
         
     | 
| 
      
 332 
     | 
    
         
            +
            "1.."
         
     | 
| 
      
 333 
     | 
    
         
            +
              ~~ operator
         
     | 
| 
      
 334 
     | 
    
         
            +
             ~~~ expression
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
            (erange (int 1) nil)
         
     | 
| 
      
 337 
     | 
    
         
            +
            "1..."
         
     | 
| 
      
 338 
     | 
    
         
            +
              ~~~ operator
         
     | 
| 
      
 339 
     | 
    
         
            +
             ~~~~ expression
         
     | 
| 
      
 340 
     | 
    
         
            +
            ~~~
         
     | 
| 
      
 341 
     | 
    
         
            +
             
     | 
| 
       325 
342 
     | 
    
         
             
            ## Access
         
     | 
| 
       326 
343 
     | 
    
         | 
| 
       327 
344 
     | 
    
         
             
            ### Self
         
     | 
| 
         @@ -1293,8 +1310,8 @@ Format: 
     | 
|
| 
       1293 
1310 
     | 
    
         
             
             ~~~~~~ keyword
         
     | 
| 
       1294 
1311 
     | 
    
         
             
                         ~~~~ begin
         
     | 
| 
       1295 
1312 
     | 
    
         
             
                                      ~~~~ else
         
     | 
| 
       1296 
     | 
    
         
            -
             
     | 
| 
       1297 
     | 
    
         
            -
              
     | 
| 
      
 1313 
     | 
    
         
            +
                                                     ~~~ end
         
     | 
| 
      
 1314 
     | 
    
         
            +
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ expression
         
     | 
| 
       1298 
1315 
     | 
    
         | 
| 
       1299 
1316 
     | 
    
         
             
            "unless cond; iftrue; else; iffalse; end"
         
     | 
| 
       1300 
1317 
     | 
    
         
             
             ~~~~~~ keyword
         
     | 
    
        data/lib/parser/ast/processor.rb
    CHANGED
    
    | 
         @@ -16,6 +16,7 @@ module Parser 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  alias on_regexp   process_regular_node
         
     | 
| 
       17 
17 
     | 
    
         
             
                  alias on_xstr     process_regular_node
         
     | 
| 
       18 
18 
     | 
    
         
             
                  alias on_splat    process_regular_node
         
     | 
| 
      
 19 
     | 
    
         
            +
                  alias on_kwsplat  process_regular_node
         
     | 
| 
       19 
20 
     | 
    
         
             
                  alias on_array    process_regular_node
         
     | 
| 
       20 
21 
     | 
    
         
             
                  alias on_pair     process_regular_node
         
     | 
| 
       21 
22 
     | 
    
         
             
                  alias on_hash     process_regular_node
         
     | 
| 
         @@ -400,12 +400,12 @@ module Parser 
     | 
|
| 
       400 
400 
     | 
    
         | 
| 
       401 
401 
     | 
    
         
             
                def range_inclusive(lhs, dot2_t, rhs)
         
     | 
| 
       402 
402 
     | 
    
         
             
                  n(:irange, [ lhs, rhs ],
         
     | 
| 
       403 
     | 
    
         
            -
                     
     | 
| 
      
 403 
     | 
    
         
            +
                    range_map(lhs, dot2_t, rhs))
         
     | 
| 
       404 
404 
     | 
    
         
             
                end
         
     | 
| 
       405 
405 
     | 
    
         | 
| 
       406 
406 
     | 
    
         
             
                def range_exclusive(lhs, dot3_t, rhs)
         
     | 
| 
       407 
407 
     | 
    
         
             
                  n(:erange, [ lhs, rhs ],
         
     | 
| 
       408 
     | 
    
         
            -
                     
     | 
| 
      
 408 
     | 
    
         
            +
                    range_map(lhs, dot3_t, rhs))
         
     | 
| 
       409 
409 
     | 
    
         
             
                end
         
     | 
| 
       410 
410 
     | 
    
         | 
| 
       411 
411 
     | 
    
         
             
                #
         
     | 
| 
         @@ -1388,6 +1388,16 @@ module Parser 
     | 
|
| 
       1388 
1388 
     | 
    
         
             
                  Source::Map::Operator.new(loc(op_t), expr_l)
         
     | 
| 
       1389 
1389 
     | 
    
         
             
                end
         
     | 
| 
       1390 
1390 
     | 
    
         | 
| 
      
 1391 
     | 
    
         
            +
                def range_map(start_e, op_t, end_e)
         
     | 
| 
      
 1392 
     | 
    
         
            +
                  if end_e
         
     | 
| 
      
 1393 
     | 
    
         
            +
                    expr_l = join_exprs(start_e, end_e)
         
     | 
| 
      
 1394 
     | 
    
         
            +
                  else
         
     | 
| 
      
 1395 
     | 
    
         
            +
                    expr_l = start_e.loc.expression.join(loc(op_t))
         
     | 
| 
      
 1396 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1397 
     | 
    
         
            +
             
     | 
| 
      
 1398 
     | 
    
         
            +
                  Source::Map::Operator.new(loc(op_t), expr_l)
         
     | 
| 
      
 1399 
     | 
    
         
            +
                end
         
     | 
| 
      
 1400 
     | 
    
         
            +
             
     | 
| 
       1391 
1401 
     | 
    
         
             
                def arg_prefix_map(op_t, name_t=nil)
         
     | 
| 
       1392 
1402 
     | 
    
         
             
                  if name_t.nil?
         
     | 
| 
       1393 
1403 
     | 
    
         
             
                    expr_l = loc(op_t)
         
     | 
    
        data/lib/parser/lexer.rl
    CHANGED
    
    | 
         @@ -1628,7 +1628,7 @@ class Parser::Lexer 
     | 
|
| 
       1628 
1628 
     | 
    
         
             
                    else
         
     | 
| 
       1629 
1629 
     | 
    
         
             
                      emit(:tLBRACE_ARG, '{'.freeze)
         
     | 
| 
       1630 
1630 
     | 
    
         
             
                    end
         
     | 
| 
       1631 
     | 
    
         
            -
                    fnext expr_value;
         
     | 
| 
      
 1631 
     | 
    
         
            +
                    fnext expr_value; fbreak;
         
     | 
| 
       1632 
1632 
     | 
    
         
             
                  };
         
     | 
| 
       1633 
1633 
     | 
    
         | 
| 
       1634 
1634 
     | 
    
         
             
                  'do'
         
     | 
| 
         @@ -2249,7 +2249,7 @@ class Parser::Lexer 
     | 
|
| 
       2249 
2249 
     | 
    
         
             
                  ( operator_arithmetic | operator_rest ) - ( '|' | '~' | '!' )
         
     | 
| 
       2250 
2250 
     | 
    
         
             
                  => {
         
     | 
| 
       2251 
2251 
     | 
    
         
             
                    emit_table(PUNCTUATION);
         
     | 
| 
       2252 
     | 
    
         
            -
                     
     | 
| 
      
 2252 
     | 
    
         
            +
                    fgoto expr_value;
         
     | 
| 
       2253 
2253 
     | 
    
         
             
                  };
         
     | 
| 
       2254 
2254 
     | 
    
         | 
| 
       2255 
2255 
     | 
    
         
             
                  ( e_lparen | '|' | '~' | '!' )
         
     | 
    
        data/lib/parser/ruby24.y
    CHANGED
    
    | 
         @@ -875,7 +875,20 @@ rule 
     | 
|
| 
       875 
875 
     | 
    
         
             
                                }
         
     | 
| 
       876 
876 
     | 
    
         
             
                              call_args
         
     | 
| 
       877 
877 
     | 
    
         
             
                                {
         
     | 
| 
       878 
     | 
    
         
            -
                                   
     | 
| 
      
 878 
     | 
    
         
            +
                                  # call_args can be followed by tLBRACE_ARG (that does cmdarg.push(0) in the lexer)
         
     | 
| 
      
 879 
     | 
    
         
            +
                                  # but the push must be done after cmdarg.pop() in the parser.
         
     | 
| 
      
 880 
     | 
    
         
            +
                                  # So this code does cmdarg.pop() to pop 0 pushed by tLBRACE_ARG,
         
     | 
| 
      
 881 
     | 
    
         
            +
                                  # cmdarg.pop() to pop 1 pushed by command_args,
         
     | 
| 
      
 882 
     | 
    
         
            +
                                  # and cmdarg.push(0) to restore back the flag set by tLBRACE_ARG.
         
     | 
| 
      
 883 
     | 
    
         
            +
                                  last_token = @last_token[0]
         
     | 
| 
      
 884 
     | 
    
         
            +
                                  lookahead = last_token == :tLBRACE_ARG
         
     | 
| 
      
 885 
     | 
    
         
            +
                                  if lookahead
         
     | 
| 
      
 886 
     | 
    
         
            +
                                    top = @lexer.cmdarg.pop
         
     | 
| 
      
 887 
     | 
    
         
            +
                                    @lexer.cmdarg.pop
         
     | 
| 
      
 888 
     | 
    
         
            +
                                    @lexer.cmdarg.push(top)
         
     | 
| 
      
 889 
     | 
    
         
            +
                                  else
         
     | 
| 
      
 890 
     | 
    
         
            +
                                    @lexer.cmdarg.pop
         
     | 
| 
      
 891 
     | 
    
         
            +
                                  end
         
     | 
| 
       879 
892 
     | 
    
         | 
| 
       880 
893 
     | 
    
         
             
                                  result = val[1]
         
     | 
| 
       881 
894 
     | 
    
         
             
                                }
         
     | 
    
        data/lib/parser/ruby25.y
    CHANGED
    
    | 
         @@ -885,7 +885,20 @@ rule 
     | 
|
| 
       885 
885 
     | 
    
         
             
                                }
         
     | 
| 
       886 
886 
     | 
    
         
             
                              call_args
         
     | 
| 
       887 
887 
     | 
    
         
             
                                {
         
     | 
| 
       888 
     | 
    
         
            -
                                   
     | 
| 
      
 888 
     | 
    
         
            +
                                  # call_args can be followed by tLBRACE_ARG (that does cmdarg.push(0) in the lexer)
         
     | 
| 
      
 889 
     | 
    
         
            +
                                  # but the push must be done after cmdarg.pop() in the parser.
         
     | 
| 
      
 890 
     | 
    
         
            +
                                  # So this code does cmdarg.pop() to pop 0 pushed by tLBRACE_ARG,
         
     | 
| 
      
 891 
     | 
    
         
            +
                                  # cmdarg.pop() to pop 1 pushed by command_args,
         
     | 
| 
      
 892 
     | 
    
         
            +
                                  # and cmdarg.push(0) to restore back the flag set by tLBRACE_ARG.
         
     | 
| 
      
 893 
     | 
    
         
            +
                                  last_token = @last_token[0]
         
     | 
| 
      
 894 
     | 
    
         
            +
                                  lookahead = last_token == :tLBRACE_ARG
         
     | 
| 
      
 895 
     | 
    
         
            +
                                  if lookahead
         
     | 
| 
      
 896 
     | 
    
         
            +
                                    top = @lexer.cmdarg.pop
         
     | 
| 
      
 897 
     | 
    
         
            +
                                    @lexer.cmdarg.pop
         
     | 
| 
      
 898 
     | 
    
         
            +
                                    @lexer.cmdarg.push(top)
         
     | 
| 
      
 899 
     | 
    
         
            +
                                  else
         
     | 
| 
      
 900 
     | 
    
         
            +
                                    @lexer.cmdarg.pop
         
     | 
| 
      
 901 
     | 
    
         
            +
                                  end
         
     | 
| 
       889 
902 
     | 
    
         | 
| 
       890 
903 
     | 
    
         
             
                                  result = val[1]
         
     | 
| 
       891 
904 
     | 
    
         
             
                                }
         
     | 
| 
         @@ -1504,7 +1517,7 @@ opt_block_args_tail: 
     | 
|
| 
       1504 
1517 
     | 
    
         
             
                                {
         
     | 
| 
       1505 
1518 
     | 
    
         
             
                                  @context.push(:lambda)
         
     | 
| 
       1506 
1519 
     | 
    
         
             
                                }
         
     | 
| 
       1507 
     | 
    
         
            -
                               
     | 
| 
      
 1520 
     | 
    
         
            +
                              compstmt kEND
         
     | 
| 
       1508 
1521 
     | 
    
         
             
                                {
         
     | 
| 
       1509 
1522 
     | 
    
         
             
                                  result = [ val[0], val[2], val[3] ]
         
     | 
| 
       1510 
1523 
     | 
    
         
             
                                  @context.pop
         
     | 
    
        data/lib/parser/ruby26.y
    CHANGED
    
    | 
         @@ -665,6 +665,14 @@ rule 
     | 
|
| 
       665 
665 
     | 
    
         
             
                                {
         
     | 
| 
       666 
666 
     | 
    
         
             
                                  result = @builder.range_exclusive(val[0], val[1], val[2])
         
     | 
| 
       667 
667 
     | 
    
         
             
                                }
         
     | 
| 
      
 668 
     | 
    
         
            +
                            | arg tDOT2
         
     | 
| 
      
 669 
     | 
    
         
            +
                                {
         
     | 
| 
      
 670 
     | 
    
         
            +
                                  result = @builder.range_inclusive(val[0], val[1], nil)
         
     | 
| 
      
 671 
     | 
    
         
            +
                                }
         
     | 
| 
      
 672 
     | 
    
         
            +
                            | arg tDOT3
         
     | 
| 
      
 673 
     | 
    
         
            +
                                {
         
     | 
| 
      
 674 
     | 
    
         
            +
                                  result = @builder.range_exclusive(val[0], val[1], nil)
         
     | 
| 
      
 675 
     | 
    
         
            +
                                }
         
     | 
| 
       668 
676 
     | 
    
         
             
                            | arg tPLUS arg
         
     | 
| 
       669 
677 
     | 
    
         
             
                                {
         
     | 
| 
       670 
678 
     | 
    
         
             
                                  result = @builder.binary_op(val[0], val[1], val[2])
         
     | 
| 
         @@ -885,7 +893,20 @@ rule 
     | 
|
| 
       885 
893 
     | 
    
         
             
                                }
         
     | 
| 
       886 
894 
     | 
    
         
             
                              call_args
         
     | 
| 
       887 
895 
     | 
    
         
             
                                {
         
     | 
| 
       888 
     | 
    
         
            -
                                   
     | 
| 
      
 896 
     | 
    
         
            +
                                  # call_args can be followed by tLBRACE_ARG (that does cmdarg.push(0) in the lexer)
         
     | 
| 
      
 897 
     | 
    
         
            +
                                  # but the push must be done after cmdarg.pop() in the parser.
         
     | 
| 
      
 898 
     | 
    
         
            +
                                  # So this code does cmdarg.pop() to pop 0 pushed by tLBRACE_ARG,
         
     | 
| 
      
 899 
     | 
    
         
            +
                                  # cmdarg.pop() to pop 1 pushed by command_args,
         
     | 
| 
      
 900 
     | 
    
         
            +
                                  # and cmdarg.push(0) to restore back the flag set by tLBRACE_ARG.
         
     | 
| 
      
 901 
     | 
    
         
            +
                                  last_token = @last_token[0]
         
     | 
| 
      
 902 
     | 
    
         
            +
                                  lookahead = last_token == :tLBRACE_ARG
         
     | 
| 
      
 903 
     | 
    
         
            +
                                  if lookahead
         
     | 
| 
      
 904 
     | 
    
         
            +
                                    top = @lexer.cmdarg.pop
         
     | 
| 
      
 905 
     | 
    
         
            +
                                    @lexer.cmdarg.pop
         
     | 
| 
      
 906 
     | 
    
         
            +
                                    @lexer.cmdarg.push(top)
         
     | 
| 
      
 907 
     | 
    
         
            +
                                  else
         
     | 
| 
      
 908 
     | 
    
         
            +
                                    @lexer.cmdarg.pop
         
     | 
| 
      
 909 
     | 
    
         
            +
                                  end
         
     | 
| 
       889 
910 
     | 
    
         | 
| 
       890 
911 
     | 
    
         
             
                                  result = val[1]
         
     | 
| 
       891 
912 
     | 
    
         
             
                                }
         
     | 
    
        data/lib/parser/source/buffer.rb
    CHANGED
    
    | 
         @@ -46,7 +46,7 @@ module Parser 
     | 
|
| 
       46 
46 
     | 
    
         
             
                  # magic encoding comment or UTF-8 BOM. `string` can be in any encoding.
         
     | 
| 
       47 
47 
     | 
    
         
             
                  #
         
     | 
| 
       48 
48 
     | 
    
         
             
                  # @param [String]  string
         
     | 
| 
       49 
     | 
    
         
            -
                  # @return [String 
     | 
| 
      
 49 
     | 
    
         
            +
                  # @return [String, nil] encoding name, if recognized
         
     | 
| 
       50 
50 
     | 
    
         
             
                  #
         
     | 
| 
       51 
51 
     | 
    
         
             
                  def self.recognize_encoding(string)
         
     | 
| 
       52 
52 
     | 
    
         
             
                    return if string.empty?
         
     | 
| 
         @@ -24,8 +24,8 @@ module Parser 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  # Associate `comments` with `ast` nodes by their corresponding node.
         
     | 
| 
       25 
25 
     | 
    
         
             
                  #
         
     | 
| 
       26 
26 
     | 
    
         
             
                  # @param [Parser::AST::Node] ast
         
     | 
| 
       27 
     | 
    
         
            -
                  # @param [Array 
     | 
| 
       28 
     | 
    
         
            -
                  # @return [Hash 
     | 
| 
      
 27 
     | 
    
         
            +
                  # @param [Array<Comment>]    comments
         
     | 
| 
      
 28 
     | 
    
         
            +
                  # @return [Hash<Parser::AST::Node, Array<Comment>>]
         
     | 
| 
       29 
29 
     | 
    
         
             
                  # @see Parser::Source::Comment::Associator#associate
         
     | 
| 
       30 
30 
     | 
    
         
             
                  # @deprecated Use {associate_locations}.
         
     | 
| 
       31 
31 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -39,8 +39,8 @@ module Parser 
     | 
|
| 
       39 
39 
     | 
    
         
             
                  # source.
         
     | 
| 
       40 
40 
     | 
    
         
             
                  #
         
     | 
| 
       41 
41 
     | 
    
         
             
                  # @param [Parser::AST::Node] ast
         
     | 
| 
       42 
     | 
    
         
            -
                  # @param [Array 
     | 
| 
       43 
     | 
    
         
            -
                  # @return [Hash 
     | 
| 
      
 42 
     | 
    
         
            +
                  # @param [Array<Comment>]    comments
         
     | 
| 
      
 43 
     | 
    
         
            +
                  # @return [Hash<Parser::Source::Map, Array<Comment>>]
         
     | 
| 
       44 
44 
     | 
    
         
             
                  # @see Parser::Source::Comment::Associator#associate_locations
         
     | 
| 
       45 
45 
     | 
    
         
             
                  #
         
     | 
| 
       46 
46 
     | 
    
         
             
                  def self.associate_locations(ast, comments)
         
     | 
| 
         @@ -47,7 +47,7 @@ module Parser 
     | 
|
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
                  ##
         
     | 
| 
       49 
49 
     | 
    
         
             
                  # @param [Parser::AST::Node] ast
         
     | 
| 
       50 
     | 
    
         
            -
                  # @param [Array 
     | 
| 
      
 50 
     | 
    
         
            +
                  # @param [Array<Parser::Source::Comment>] comments
         
     | 
| 
       51 
51 
     | 
    
         
             
                  def initialize(ast, comments)
         
     | 
| 
       52 
52 
     | 
    
         
             
                    @ast         = ast
         
     | 
| 
       53 
53 
     | 
    
         
             
                    @comments    = comments
         
     | 
| 
         @@ -85,7 +85,7 @@ module Parser 
     | 
|
| 
       85 
85 
     | 
    
         
             
                  # Note that {associate} produces unexpected result for nodes which are
         
     | 
| 
       86 
86 
     | 
    
         
             
                  # equal but have distinct locations; comments for these nodes are merged.
         
     | 
| 
       87 
87 
     | 
    
         
             
                  #
         
     | 
| 
       88 
     | 
    
         
            -
                  # @return [Hash 
     | 
| 
      
 88 
     | 
    
         
            +
                  # @return [Hash<Parser::AST::Node, Array<Parser::Source::Comment>>]
         
     | 
| 
       89 
89 
     | 
    
         
             
                  # @deprecated Use {associate_locations}.
         
     | 
| 
       90 
90 
     | 
    
         
             
                  #
         
     | 
| 
       91 
91 
     | 
    
         
             
                  def associate
         
     | 
| 
         @@ -98,7 +98,7 @@ module Parser 
     | 
|
| 
       98 
98 
     | 
    
         
             
                  # the hash key, thus producing an unambiguous result even in presence
         
     | 
| 
       99 
99 
     | 
    
         
             
                  # of equal nodes.
         
     | 
| 
       100 
100 
     | 
    
         
             
                  #
         
     | 
| 
       101 
     | 
    
         
            -
                  # @return [Hash 
     | 
| 
      
 101 
     | 
    
         
            +
                  # @return [Hash<Parser::Source::Map, Array<Parser::Source::Comment>>]
         
     | 
| 
       102 
102 
     | 
    
         
             
                  #
         
     | 
| 
       103 
103 
     | 
    
         
             
                  def associate_locations
         
     | 
| 
       104 
104 
     | 
    
         
             
                    @map_using_locations = true
         
     | 
    
        data/lib/parser/source/map.rb
    CHANGED
    
    | 
         @@ -161,7 +161,7 @@ module Parser 
     | 
|
| 
       161 
161 
     | 
    
         
             
                  #  #   :expression => #<Source::Range (string) 0...6>
         
     | 
| 
       162 
162 
     | 
    
         
             
                  #  # }
         
     | 
| 
       163 
163 
     | 
    
         
             
                  #
         
     | 
| 
       164 
     | 
    
         
            -
                  # @return [Hash 
     | 
| 
      
 164 
     | 
    
         
            +
                  # @return [Hash<Symbol, Parser::Source::Range>]
         
     | 
| 
       165 
165 
     | 
    
         
             
                  #
         
     | 
| 
       166 
166 
     | 
    
         
             
                  def to_hash
         
     | 
| 
       167 
167 
     | 
    
         
             
                    instance_variables.inject({}) do |hash, ivar|
         
     | 
    
        data/lib/parser/source/range.rb
    CHANGED
    
    
| 
         @@ -133,8 +133,8 @@ module Parser 
     | 
|
| 
       133 
133 
     | 
    
         
             
                  # Inserts the given strings before and after the given range.
         
     | 
| 
       134 
134 
     | 
    
         
             
                  #
         
     | 
| 
       135 
135 
     | 
    
         
             
                  # @param [Range] range
         
     | 
| 
       136 
     | 
    
         
            -
                  # @param [String  
     | 
| 
       137 
     | 
    
         
            -
                  # @param [String  
     | 
| 
      
 136 
     | 
    
         
            +
                  # @param [String, nil] insert_before
         
     | 
| 
      
 137 
     | 
    
         
            +
                  # @param [String, nil] insert_after
         
     | 
| 
       138 
138 
     | 
    
         
             
                  # @return [Rewriter] self
         
     | 
| 
       139 
139 
     | 
    
         
             
                  # @raise [ClobberingError] when clobbering is detected
         
     | 
| 
       140 
140 
     | 
    
         
             
                  #
         
     | 
    
        data/lib/parser/version.rb
    CHANGED
    
    
    
        data/test/parse_helper.rb
    CHANGED
    
    | 
         @@ -124,7 +124,7 @@ module ParseHelper 
     | 
|
| 
       124 
124 
     | 
    
         
             
                  assert_source_range(begin_pos, end_pos, range, version, line.inspect)
         
     | 
| 
       125 
125 
     | 
    
         
             
                end
         
     | 
| 
       126 
126 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
                 
     | 
| 
      
 127 
     | 
    
         
            +
                assert parser.instance_eval { @lexer }.cmdarg.empty?,
         
     | 
| 
       128 
128 
     | 
    
         
             
                  "(#{version}) expected cmdarg to be empty after parsing"
         
     | 
| 
       129 
129 
     | 
    
         
             
              end
         
     | 
| 
       130 
130 
     | 
    
         | 
    
        data/test/test_parser.rb
    CHANGED
    
    | 
         @@ -833,6 +833,24 @@ class TestParser < Minitest::Test 
     | 
|
| 
       833 
833 
     | 
    
         
             
                    |~~~~~ expression})
         
     | 
| 
       834 
834 
     | 
    
         
             
              end
         
     | 
| 
       835 
835 
     | 
    
         | 
| 
      
 836 
     | 
    
         
            +
              def test_range_endless
         
     | 
| 
      
 837 
     | 
    
         
            +
                assert_parses(
         
     | 
| 
      
 838 
     | 
    
         
            +
                  s(:irange,
         
     | 
| 
      
 839 
     | 
    
         
            +
                    s(:int, 1), nil),
         
     | 
| 
      
 840 
     | 
    
         
            +
                  %q{1..},
         
     | 
| 
      
 841 
     | 
    
         
            +
                  %q{~~~ expression
         
     | 
| 
      
 842 
     | 
    
         
            +
                    | ~~ operator},
         
     | 
| 
      
 843 
     | 
    
         
            +
                  SINCE_2_6)
         
     | 
| 
      
 844 
     | 
    
         
            +
             
     | 
| 
      
 845 
     | 
    
         
            +
                assert_parses(
         
     | 
| 
      
 846 
     | 
    
         
            +
                  s(:erange,
         
     | 
| 
      
 847 
     | 
    
         
            +
                    s(:int, 1), nil),
         
     | 
| 
      
 848 
     | 
    
         
            +
                  %q{1...},
         
     | 
| 
      
 849 
     | 
    
         
            +
                  %q{~~~~ expression
         
     | 
| 
      
 850 
     | 
    
         
            +
                    | ~~~ operator},
         
     | 
| 
      
 851 
     | 
    
         
            +
                  SINCE_2_6)
         
     | 
| 
      
 852 
     | 
    
         
            +
              end
         
     | 
| 
      
 853 
     | 
    
         
            +
             
     | 
| 
       836 
854 
     | 
    
         
             
              #
         
     | 
| 
       837 
855 
     | 
    
         
             
              # Access
         
     | 
| 
       838 
856 
     | 
    
         
             
              #
         
     | 
| 
         @@ -6658,7 +6676,7 @@ class TestParser < Minitest::Test 
     | 
|
| 
       6658 
6676 
     | 
    
         
             
                  [:error, :unexpected_token, { :token => 'kRESCUE'}],
         
     | 
| 
       6659 
6677 
     | 
    
         
             
                  %q{-> do rescue; end},
         
     | 
| 
       6660 
6678 
     | 
    
         
             
                  %q{      ~~~~~~ location},
         
     | 
| 
       6661 
     | 
    
         
            -
                  SINCE_1_9 -  
     | 
| 
      
 6679 
     | 
    
         
            +
                  SINCE_1_9 - SINCE_2_6)
         
     | 
| 
       6662 
6680 
     | 
    
         | 
| 
       6663 
6681 
     | 
    
         
             
                assert_parses(
         
     | 
| 
       6664 
6682 
     | 
    
         
             
                  s(:block,
         
     | 
| 
         @@ -6668,7 +6686,7 @@ class TestParser < Minitest::Test 
     | 
|
| 
       6668 
6686 
     | 
    
         
             
                      s(:resbody, nil, nil, nil), nil)),
         
     | 
| 
       6669 
6687 
     | 
    
         
             
                  %q{-> do rescue; end},
         
     | 
| 
       6670 
6688 
     | 
    
         
             
                  %q{      ~~~~~~ keyword (rescue.resbody)},
         
     | 
| 
       6671 
     | 
    
         
            -
                   
     | 
| 
      
 6689 
     | 
    
         
            +
                  SINCE_2_6)
         
     | 
| 
       6672 
6690 
     | 
    
         | 
| 
       6673 
6691 
     | 
    
         
             
                assert_diagnoses(
         
     | 
| 
       6674 
6692 
     | 
    
         
             
                  [:error, :unexpected_token, { :token => 'kRESCUE'}],
         
     | 
| 
         @@ -6965,4 +6983,46 @@ class TestParser < Minitest::Test 
     | 
|
| 
       6965 
6983 
     | 
    
         
             
                  %q{      ^ location},
         
     | 
| 
       6966 
6984 
     | 
    
         
             
                  SINCE_2_2)
         
     | 
| 
       6967 
6985 
     | 
    
         
             
              end
         
     | 
| 
      
 6986 
     | 
    
         
            +
             
     | 
| 
      
 6987 
     | 
    
         
            +
              def test_lbrace_arg_after_command_args
         
     | 
| 
      
 6988 
     | 
    
         
            +
                assert_parses(
         
     | 
| 
      
 6989 
     | 
    
         
            +
                  s(:block,
         
     | 
| 
      
 6990 
     | 
    
         
            +
                    s(:send, nil, :let,
         
     | 
| 
      
 6991 
     | 
    
         
            +
                      s(:begin,
         
     | 
| 
      
 6992 
     | 
    
         
            +
                        s(:sym, :a))),
         
     | 
| 
      
 6993 
     | 
    
         
            +
                    s(:args),
         
     | 
| 
      
 6994 
     | 
    
         
            +
                    s(:block,
         
     | 
| 
      
 6995 
     | 
    
         
            +
                      s(:send, nil, :m),
         
     | 
| 
      
 6996 
     | 
    
         
            +
                      s(:args), nil)),
         
     | 
| 
      
 6997 
     | 
    
         
            +
                  %q{let (:a) { m do; end }},
         
     | 
| 
      
 6998 
     | 
    
         
            +
                  %q{},
         
     | 
| 
      
 6999 
     | 
    
         
            +
                  ALL_VERSIONS)
         
     | 
| 
      
 7000 
     | 
    
         
            +
              end
         
     | 
| 
      
 7001 
     | 
    
         
            +
             
     | 
| 
      
 7002 
     | 
    
         
            +
              def test_ruby_bug_14690
         
     | 
| 
      
 7003 
     | 
    
         
            +
                assert_parses(
         
     | 
| 
      
 7004 
     | 
    
         
            +
                  s(:block,
         
     | 
| 
      
 7005 
     | 
    
         
            +
                    s(:send, nil, :let,
         
     | 
| 
      
 7006 
     | 
    
         
            +
                      s(:begin)),
         
     | 
| 
      
 7007 
     | 
    
         
            +
                    s(:args),
         
     | 
| 
      
 7008 
     | 
    
         
            +
                    s(:block,
         
     | 
| 
      
 7009 
     | 
    
         
            +
                      s(:send, nil, :m,
         
     | 
| 
      
 7010 
     | 
    
         
            +
                        s(:send, nil, :a)),
         
     | 
| 
      
 7011 
     | 
    
         
            +
                      s(:args), nil)),
         
     | 
| 
      
 7012 
     | 
    
         
            +
                  %q{let () { m(a) do; end }},
         
     | 
| 
      
 7013 
     | 
    
         
            +
                  %q{},
         
     | 
| 
      
 7014 
     | 
    
         
            +
                  SINCE_2_0)
         
     | 
| 
      
 7015 
     | 
    
         
            +
              end
         
     | 
| 
      
 7016 
     | 
    
         
            +
             
     | 
| 
      
 7017 
     | 
    
         
            +
              def test_parser_bug_507
         
     | 
| 
      
 7018 
     | 
    
         
            +
                assert_parses(
         
     | 
| 
      
 7019 
     | 
    
         
            +
                  s(:lvasgn, :m,
         
     | 
| 
      
 7020 
     | 
    
         
            +
                    s(:block,
         
     | 
| 
      
 7021 
     | 
    
         
            +
                      s(:lambda),
         
     | 
| 
      
 7022 
     | 
    
         
            +
                      s(:args,
         
     | 
| 
      
 7023 
     | 
    
         
            +
                        s(:restarg, :args)), nil)),
         
     | 
| 
      
 7024 
     | 
    
         
            +
                  %q{m = -> *args do end},
         
     | 
| 
      
 7025 
     | 
    
         
            +
                  %q{},
         
     | 
| 
      
 7026 
     | 
    
         
            +
                  SINCE_1_9)
         
     | 
| 
      
 7027 
     | 
    
         
            +
              end
         
     | 
| 
       6968 
7028 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: parser
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.5.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.5.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - whitequark
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-07-10 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: ast
         
     |