ruby_parser 3.11.0 → 3.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +12 -0
- data/lib/ruby18_parser.rb +472 -472
- data/lib/ruby21_parser.rb +47 -47
- data/lib/ruby25_parser.rb +71 -71
- data/lib/ruby25_parser.y +1 -1
- data/lib/ruby_lexer.rb +16 -3
- data/lib/ruby_lexer.rex +2 -2
- data/lib/ruby_lexer.rex.rb +2 -2
- data/lib/ruby_parser.rb +5 -1
- data/lib/ruby_parser.yy +4 -0
- data/lib/ruby_parser_extras.rb +4 -3
- data/test/test_ruby_lexer.rb +51 -0
- data/test/test_ruby_parser.rb +80 -0
- metadata +6 -6
- metadata.gz.sig +0 -0
data/test/test_ruby_lexer.rb
CHANGED
@@ -494,6 +494,19 @@ class TestRubyLexer < Minitest::Test
|
|
494
494
|
:tRCURLY, "}", :expr_endarg, 0, 0)
|
495
495
|
end
|
496
496
|
|
497
|
+
def test_yylex_lambda_as_args_with_block__20
|
498
|
+
setup_lexer_class RubyParser::V20
|
499
|
+
|
500
|
+
assert_lex3("a -> do end do end",
|
501
|
+
nil,
|
502
|
+
:tIDENTIFIER, "a", :expr_cmdarg,
|
503
|
+
:tLAMBDA, nil, :expr_endfn,
|
504
|
+
:kDO, "do", :expr_beg,
|
505
|
+
:kEND, "end", :expr_end,
|
506
|
+
:kDO_BLOCK, "do", :expr_beg,
|
507
|
+
:kEND, "end", :expr_end)
|
508
|
+
end
|
509
|
+
|
497
510
|
def test_yylex_lambda_args_opt__20
|
498
511
|
setup_lexer_class RubyParser::V20
|
499
512
|
|
@@ -2598,6 +2611,10 @@ class TestRubyLexer < Minitest::Test
|
|
2598
2611
|
assert_lex3("'blah\\\nblah'", nil, :tSTRING, "blah\\\nblah", :expr_end)
|
2599
2612
|
end
|
2600
2613
|
|
2614
|
+
def test_yylex_string_single_escaped_quote
|
2615
|
+
assert_lex3("'foo\\'bar'", nil, :tSTRING, "foo'bar", :expr_end)
|
2616
|
+
end
|
2617
|
+
|
2601
2618
|
def test_yylex_symbol
|
2602
2619
|
assert_lex3(":symbol", nil, :tSYMBOL, "symbol", :expr_end)
|
2603
2620
|
end
|
@@ -2641,6 +2658,16 @@ class TestRubyLexer < Minitest::Test
|
|
2641
2658
|
:tSYMBOL, 'symbol#{1+1}', :expr_end)
|
2642
2659
|
end
|
2643
2660
|
|
2661
|
+
def test_yylex_symbol_single_escape_chars
|
2662
|
+
assert_lex3(":'s\\tri\\ng'",
|
2663
|
+
nil,
|
2664
|
+
:tSYMBOL, "s\\tri\\ng", :expr_end)
|
2665
|
+
end
|
2666
|
+
|
2667
|
+
def test_yylex_string_single_escape_quote_and_backslash
|
2668
|
+
assert_lex3(":'foo\\'bar\\\\baz'", nil, :tSYMBOL, "foo'bar\\baz", :expr_end)
|
2669
|
+
end
|
2670
|
+
|
2644
2671
|
def test_yylex_ternary1
|
2645
2672
|
assert_lex3("a ? b : c",
|
2646
2673
|
nil,
|
@@ -2819,6 +2846,30 @@ class TestRubyLexer < Minitest::Test
|
|
2819
2846
|
:kEND, "end", :expr_end)
|
2820
2847
|
end
|
2821
2848
|
|
2849
|
+
def test_yylex_hash_colon_double_quoted_with_escapes
|
2850
|
+
setup_lexer_class RubyParser::V22
|
2851
|
+
|
2852
|
+
assert_lex3("{\"s\\tr\\i\\ng\\\\foo\\'bar\":1}",
|
2853
|
+
nil,
|
2854
|
+
|
2855
|
+
:tLBRACE, "{", :expr_beg,
|
2856
|
+
:tLABEL, "s\tr\i\ng\\foo'bar", :expr_labelarg,
|
2857
|
+
:tINTEGER, 1, :expr_end,
|
2858
|
+
:tRCURLY, "}", :expr_endarg)
|
2859
|
+
end
|
2860
|
+
|
2861
|
+
def test_yylex_hash_colon_quoted_with_escapes
|
2862
|
+
setup_lexer_class RubyParser::V22
|
2863
|
+
|
2864
|
+
assert_lex3("{'s\\tr\\i\\ng\\\\foo\\'bar':1}",
|
2865
|
+
nil,
|
2866
|
+
|
2867
|
+
:tLBRACE, "{", :expr_beg,
|
2868
|
+
:tLABEL, "s\\tr\\i\\ng\\foo'bar", :expr_labelarg,
|
2869
|
+
:tINTEGER, 1, :expr_end,
|
2870
|
+
:tRCURLY, "}", :expr_endarg)
|
2871
|
+
end
|
2872
|
+
|
2822
2873
|
def test_ruby21_rational_literal
|
2823
2874
|
setup_lexer_class RubyParser::V21
|
2824
2875
|
|
data/test/test_ruby_parser.rb
CHANGED
@@ -2029,6 +2029,20 @@ module TestRubyParserShared19Plus
|
|
2029
2029
|
assert_parse rb, pt
|
2030
2030
|
end
|
2031
2031
|
|
2032
|
+
def test_call_stabby_with_braces_block
|
2033
|
+
rb = "a -> {} do\nend"
|
2034
|
+
pt = s(:iter, s(:call, nil, :a, s(:iter, s(:call, nil, :lambda), 0)), 0)
|
2035
|
+
|
2036
|
+
assert_parse rb, pt
|
2037
|
+
end
|
2038
|
+
|
2039
|
+
def test_call_stabby_do_end_with_block
|
2040
|
+
rb = "a -> do end do end"
|
2041
|
+
pt = s(:iter, s(:call, nil, :a, s(:iter, s(:call, nil, :lambda), 0)), 0)
|
2042
|
+
|
2043
|
+
assert_parse rb, pt
|
2044
|
+
end
|
2045
|
+
|
2032
2046
|
def test_call_trailing_comma
|
2033
2047
|
rb = "f(1,)"
|
2034
2048
|
pt = s(:call, nil, :f, s(:lit, 1))
|
@@ -3766,6 +3780,72 @@ class TestRubyParserV25 < RubyParserTestCase
|
|
3766
3780
|
|
3767
3781
|
self.processor = RubyParser::V25.new
|
3768
3782
|
end
|
3783
|
+
|
3784
|
+
def test_rescue_in_block
|
3785
|
+
rb = "blah do\nrescue\n stuff\nend"
|
3786
|
+
pt = s(:iter, s(:call, nil, :blah), 0, s(:rescue, s(:resbody, s(:array), s(:call, nil, :stuff))))
|
3787
|
+
assert_parse rb, pt
|
3788
|
+
end
|
3789
|
+
|
3790
|
+
def test_rescue_do_end_raised
|
3791
|
+
rb = "tap do\n raise\nensure\n :ensure\nend"
|
3792
|
+
pt = s(:iter,
|
3793
|
+
s(:call, nil, :tap),
|
3794
|
+
0,
|
3795
|
+
s(:ensure,
|
3796
|
+
s(:call, nil, :raise),
|
3797
|
+
s(:lit, :ensure)))
|
3798
|
+
|
3799
|
+
assert_parse rb, pt
|
3800
|
+
end
|
3801
|
+
|
3802
|
+
def test_rescue_do_end_rescued
|
3803
|
+
rb = "tap do\n raise\nrescue\n :rescue\nelse\n :else\nensure\n :ensure\nend"
|
3804
|
+
pt = s(:iter,
|
3805
|
+
s(:call, nil, :tap),
|
3806
|
+
0,
|
3807
|
+
s(:ensure,
|
3808
|
+
s(:rescue,
|
3809
|
+
s(:call, nil, :raise),
|
3810
|
+
s(:resbody,
|
3811
|
+
s(:array),
|
3812
|
+
s(:lit, :rescue)),
|
3813
|
+
s(:lit, :else)),
|
3814
|
+
s(:lit, :ensure)))
|
3815
|
+
|
3816
|
+
assert_parse rb, pt
|
3817
|
+
end
|
3818
|
+
|
3819
|
+
def test_rescue_do_end_no_raise
|
3820
|
+
rb = "tap do\n :begin\nrescue\n :rescue\nelse\n :else\nensure\n :ensure\nend"
|
3821
|
+
pt = s(:iter,
|
3822
|
+
s(:call, nil, :tap),
|
3823
|
+
0,
|
3824
|
+
s(:ensure,
|
3825
|
+
s(:rescue,
|
3826
|
+
s(:lit, :begin),
|
3827
|
+
s(:resbody,
|
3828
|
+
s(:array),
|
3829
|
+
s(:lit, :rescue)),
|
3830
|
+
s(:lit, :else)),
|
3831
|
+
s(:lit, :ensure)))
|
3832
|
+
|
3833
|
+
assert_parse rb, pt
|
3834
|
+
end
|
3835
|
+
|
3836
|
+
def test_rescue_do_end_ensure_result
|
3837
|
+
rb = "proc do\n :begin\nensure\n :ensure\nend.call"
|
3838
|
+
pt = s(:call,
|
3839
|
+
s(:iter,
|
3840
|
+
s(:call, nil, :proc),
|
3841
|
+
0,
|
3842
|
+
s(:ensure,
|
3843
|
+
s(:lit, :begin),
|
3844
|
+
s(:lit, :ensure))),
|
3845
|
+
:call)
|
3846
|
+
|
3847
|
+
assert_parse rb, pt
|
3848
|
+
end
|
3769
3849
|
end
|
3770
3850
|
|
3771
3851
|
RubyParser::VERSIONS.each do |klass|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
AhXhF6Wi2GTMezlj5jlI5XV7WsJUSwTp/YiVvcmT74ZaCRvexm6EnNhkrvJJ1Xeu
|
30
30
|
V+HB+LYYhXWitInO/eXxDrFB
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2018-
|
32
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: sexp_processor
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
version: '4.0'
|
83
83
|
- - "<"
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
85
|
+
version: '7'
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -92,7 +92,7 @@ dependencies:
|
|
92
92
|
version: '4.0'
|
93
93
|
- - "<"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '7'
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
97
|
name: racc
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,14 +113,14 @@ dependencies:
|
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '3.
|
116
|
+
version: '3.17'
|
117
117
|
type: :development
|
118
118
|
prerelease: false
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '3.
|
123
|
+
version: '3.17'
|
124
124
|
description: |-
|
125
125
|
ruby_parser (RP) is a ruby parser written in pure ruby (utilizing
|
126
126
|
racc--which does by default use a C extension). RP's output is
|
metadata.gz.sig
CHANGED
Binary file
|