parser 2.6.0.0 → 2.6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -9
- data/CHANGELOG.md +13 -0
- data/Rakefile +1 -0
- data/doc/AST_FORMAT.md +12 -0
- data/lib/parser/all.rb +1 -0
- data/lib/parser/builders/default.rb +5 -0
- data/lib/parser/current.rb +11 -2
- data/lib/parser/lexer.rl +10 -9
- data/lib/parser/ruby27.y +2415 -0
- data/lib/parser/runner.rb +5 -0
- data/lib/parser/tree_rewriter.rb +2 -1
- data/lib/parser/version.rb +1 -1
- data/parser.gemspec +2 -1
- data/test/parse_helper.rb +2 -1
- data/test/test_current.rb +2 -0
- data/test/test_lexer.rb +41 -0
- data/test/test_parser.rb +33 -0
- metadata +13 -6
data/lib/parser/runner.rb
CHANGED
@@ -106,6 +106,11 @@ module Parser
|
|
106
106
|
@parser_class = Parser::Ruby26
|
107
107
|
end
|
108
108
|
|
109
|
+
opts.on '--27', 'Parse as Ruby 2.7 would' do
|
110
|
+
require 'parser/ruby27'
|
111
|
+
@parser_class = Parser::Ruby27
|
112
|
+
end
|
113
|
+
|
109
114
|
opts.on '--mac', 'Parse as MacRuby 0.12 would' do
|
110
115
|
require 'parser/macruby'
|
111
116
|
@parser_class = Parser::MacRuby
|
data/lib/parser/tree_rewriter.rb
CHANGED
@@ -27,12 +27,13 @@ module Parser
|
|
27
27
|
# end
|
28
28
|
# EOF
|
29
29
|
#
|
30
|
+
# ast = Parser::CurrentRuby.parse code
|
30
31
|
# buffer = Parser::Source::Buffer.new('(example)')
|
31
32
|
# buffer.source = code
|
32
33
|
# rewriter = RemoveDo.new
|
33
34
|
#
|
34
35
|
# # Rewrite the AST, returns a String with the new form.
|
35
|
-
# puts rewriter.rewrite(buffer)
|
36
|
+
# puts rewriter.rewrite(buffer, ast)
|
36
37
|
#
|
37
38
|
# This would result in the following Ruby code:
|
38
39
|
#
|
data/lib/parser/version.rb
CHANGED
data/parser.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
lib/parser/ruby24.rb
|
25
25
|
lib/parser/ruby25.rb
|
26
26
|
lib/parser/ruby26.rb
|
27
|
+
lib/parser/ruby27.rb
|
27
28
|
lib/parser/macruby.rb
|
28
29
|
lib/parser/rubymotion.rb
|
29
30
|
)
|
@@ -35,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
35
36
|
|
36
37
|
spec.add_dependency 'ast', '~> 2.4.0'
|
37
38
|
|
38
|
-
spec.add_development_dependency 'bundler', '
|
39
|
+
spec.add_development_dependency 'bundler', '>= 1.15', '< 3.0.0'
|
39
40
|
spec.add_development_dependency 'rake', '~> 10.0'
|
40
41
|
spec.add_development_dependency 'racc', '= 1.4.14'
|
41
42
|
spec.add_development_dependency 'cliver', '~> 0.3.2'
|
data/test/parse_helper.rb
CHANGED
@@ -7,7 +7,7 @@ module ParseHelper
|
|
7
7
|
require 'parser/macruby'
|
8
8
|
require 'parser/rubymotion'
|
9
9
|
|
10
|
-
ALL_VERSIONS = %w(1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 mac ios)
|
10
|
+
ALL_VERSIONS = %w(1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 mac ios)
|
11
11
|
|
12
12
|
def setup
|
13
13
|
@diagnostics = []
|
@@ -26,6 +26,7 @@ module ParseHelper
|
|
26
26
|
when '2.4' then parser = Parser::Ruby24.new
|
27
27
|
when '2.5' then parser = Parser::Ruby25.new
|
28
28
|
when '2.6' then parser = Parser::Ruby26.new
|
29
|
+
when '2.7' then parser = Parser::Ruby27.new
|
29
30
|
when 'mac' then parser = Parser::MacRuby.new
|
30
31
|
when 'ios' then parser = Parser::RubyMotion.new
|
31
32
|
else raise "Unrecognized Ruby version #{version}"
|
data/test/test_current.rb
CHANGED
@@ -20,6 +20,8 @@ class TestCurrent < Minitest::Test
|
|
20
20
|
assert_equal Parser::Ruby25, Parser::CurrentRuby
|
21
21
|
when /^2\.6\.\d+/
|
22
22
|
assert_equal Parser::Ruby26, Parser::CurrentRuby
|
23
|
+
when /^2\.7\.\d+/
|
24
|
+
assert_equal Parser::Ruby27, Parser::CurrentRuby
|
23
25
|
else
|
24
26
|
flunk "Update test_current for #{RUBY_VERSION}"
|
25
27
|
end
|
data/test/test_lexer.rb
CHANGED
@@ -3540,4 +3540,45 @@ class TestLexer < Minitest::Test
|
|
3540
3540
|
:tIDENTIFIER, 're', [1, 3])
|
3541
3541
|
end
|
3542
3542
|
|
3543
|
+
def test_meth_ref
|
3544
|
+
assert_scanned('foo.:bar',
|
3545
|
+
:tIDENTIFIER, 'foo', [0, 3],
|
3546
|
+
:tMETHREF, '.:', [3, 5],
|
3547
|
+
:tIDENTIFIER, 'bar', [5, 8])
|
3548
|
+
|
3549
|
+
assert_scanned('foo .:bar',
|
3550
|
+
:tIDENTIFIER, 'foo', [0, 3],
|
3551
|
+
:tMETHREF, '.:', [4, 6],
|
3552
|
+
:tIDENTIFIER, 'bar', [6, 9])
|
3553
|
+
end
|
3554
|
+
|
3555
|
+
def test_meth_ref_unary_op
|
3556
|
+
assert_scanned('foo.:+',
|
3557
|
+
:tIDENTIFIER, 'foo', [0, 3],
|
3558
|
+
:tMETHREF, '.:', [3, 5],
|
3559
|
+
:tPLUS, '+', [5, 6])
|
3560
|
+
|
3561
|
+
assert_scanned('foo.:-@',
|
3562
|
+
:tIDENTIFIER, 'foo', [0, 3],
|
3563
|
+
:tMETHREF, '.:', [3, 5],
|
3564
|
+
:tUMINUS, '-@', [5, 7])
|
3565
|
+
end
|
3566
|
+
|
3567
|
+
def test_meth_ref_unsupported_newlines
|
3568
|
+
# MRI emits exactly the same sequence of tokens,
|
3569
|
+
# the error happens later in the parser
|
3570
|
+
|
3571
|
+
assert_scanned('foo. :+',
|
3572
|
+
:tIDENTIFIER, 'foo', [0, 3],
|
3573
|
+
:tDOT, '.', [3, 4],
|
3574
|
+
:tCOLON, ':', [5, 6],
|
3575
|
+
:tUPLUS, '+', [6, 7])
|
3576
|
+
|
3577
|
+
assert_scanned('foo.: +',
|
3578
|
+
:tIDENTIFIER, 'foo', [0, 3],
|
3579
|
+
:tDOT, '.', [3, 4],
|
3580
|
+
:tCOLON, ':', [4, 5],
|
3581
|
+
:tPLUS, '+', [6, 7])
|
3582
|
+
end
|
3583
|
+
|
3543
3584
|
end
|
data/test/test_parser.rb
CHANGED
@@ -28,6 +28,7 @@ class TestParser < Minitest::Test
|
|
28
28
|
SINCE_2_4 = SINCE_2_3 - %w(2.3)
|
29
29
|
SINCE_2_5 = SINCE_2_4 - %w(2.4)
|
30
30
|
SINCE_2_6 = SINCE_2_5 - %w(2.5)
|
31
|
+
SINCE_2_7 = SINCE_2_6 - %w(2.6)
|
31
32
|
|
32
33
|
# Guidelines for test naming:
|
33
34
|
# * Test structure follows structure of AST_FORMAT.md.
|
@@ -7084,4 +7085,36 @@ class TestParser < Minitest::Test
|
|
7084
7085
|
SINCE_2_0)
|
7085
7086
|
end
|
7086
7087
|
end
|
7088
|
+
|
7089
|
+
def test_meth_ref
|
7090
|
+
assert_parses(
|
7091
|
+
s(:meth_ref, s(:lvar, :foo), :bar),
|
7092
|
+
%q{foo.:bar},
|
7093
|
+
%q{ ^^ dot
|
7094
|
+
| ~~~ selector
|
7095
|
+
|~~~~~~~~ expression},
|
7096
|
+
SINCE_2_7)
|
7097
|
+
|
7098
|
+
assert_parses(
|
7099
|
+
s(:meth_ref, s(:lvar, :foo), :+@),
|
7100
|
+
%q{foo.:+@},
|
7101
|
+
%q{ ^^ dot
|
7102
|
+
| ~~ selector
|
7103
|
+
|~~~~~~~ expression},
|
7104
|
+
SINCE_2_7)
|
7105
|
+
end
|
7106
|
+
|
7107
|
+
def test_meth_ref_unsupported_newlines
|
7108
|
+
assert_diagnoses(
|
7109
|
+
[:error, :unexpected_token, { :token => 'tCOLON' }],
|
7110
|
+
%Q{foo. :+},
|
7111
|
+
%q{ ^ location},
|
7112
|
+
SINCE_2_7)
|
7113
|
+
|
7114
|
+
assert_diagnoses(
|
7115
|
+
[:error, :unexpected_token, { :token => 'tCOLON' }],
|
7116
|
+
%Q{foo.: +},
|
7117
|
+
%q{ ^ location},
|
7118
|
+
SINCE_2_7)
|
7119
|
+
end
|
7087
7120
|
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.6.
|
4
|
+
version: 2.6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- whitequark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.15'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.0.0
|
34
37
|
type: :development
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '1.15'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.0.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rake
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +225,8 @@ files:
|
|
219
225
|
- lib/parser/ruby25.y
|
220
226
|
- lib/parser/ruby26.rb
|
221
227
|
- lib/parser/ruby26.y
|
228
|
+
- lib/parser/ruby27.rb
|
229
|
+
- lib/parser/ruby27.y
|
222
230
|
- lib/parser/rubymotion.rb
|
223
231
|
- lib/parser/rubymotion.y
|
224
232
|
- lib/parser/runner.rb
|
@@ -299,8 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
307
|
- !ruby/object:Gem::Version
|
300
308
|
version: '0'
|
301
309
|
requirements: []
|
302
|
-
|
303
|
-
rubygems_version: 2.7.6
|
310
|
+
rubygems_version: 3.0.1
|
304
311
|
signing_key:
|
305
312
|
specification_version: 4
|
306
313
|
summary: A Ruby parser written in pure Ruby.
|