parser 2.5.0.2 → 2.5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/parser/current.rb +1 -1
- data/lib/parser/lexer.rl +8 -1
- data/lib/parser/lexer/literal.rb +1 -1
- data/lib/parser/source/buffer.rb +2 -2
- data/lib/parser/source/rewriter.rb +1 -1
- data/lib/parser/source/tree_rewriter.rb +1 -1
- data/lib/parser/version.rb +1 -1
- data/parser.gemspec +1 -1
- data/test/test_encoding.rb +1 -0
- data/test/test_parser.rb +20 -3
- data/test/test_source_buffer.rb +6 -0
- data/test/test_source_rewriter.rb +1 -1
- data/test/test_source_tree_rewriter.rb +5 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b09926b92e95874cfa6295ffa913a0d282c063d
|
4
|
+
data.tar.gz: 10036043ab11e9fd97f36ddf29615f8f25247b78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78ade228a7b0d40884bd06a6b2241d1282693f15d359bf73e0ae4f56e08b90da90586ecca947666fdf00b5d2a6a9ec7851627cd870a00cab49eafe6368c245fa
|
7
|
+
data.tar.gz: f4109e28f013c637ad30b616115037264756b05eadfde190987564831b1f3ef9071cfafc764b731098639524f28c06d80738437a8c60f4d0062de3cf52daf1ec
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
Not released (2018-03-06)
|
5
|
+
-------------------------
|
6
|
+
|
7
|
+
Bugs fixed:
|
8
|
+
* Accept `BEGIN` and `END` as correct method name (#463) (Masataka Pocke Kuwabara)
|
9
|
+
* Parser::Source::Buffer: Fixed parsing of encoding comment when the file contains only shebang. (Ilya Bylich)
|
10
|
+
|
4
11
|
v2.5.0.2 (2018-02-22)
|
5
12
|
---------------------
|
6
13
|
|
data/lib/parser/current.rb
CHANGED
data/lib/parser/lexer.rl
CHANGED
@@ -467,6 +467,7 @@ class Parser::Lexer
|
|
467
467
|
'if' => :kIF, 'unless' => :kUNLESS,
|
468
468
|
'while' => :kWHILE, 'until' => :kUNTIL,
|
469
469
|
'rescue' => :kRESCUE, 'defined?' => :kDEFINED,
|
470
|
+
'BEGIN' => :klBEGIN, 'END' => :klEND,
|
470
471
|
}
|
471
472
|
|
472
473
|
%w(class module def undef begin end then elsif else ensure case when
|
@@ -2219,7 +2220,13 @@ class Parser::Lexer
|
|
2219
2220
|
e_rbrace | e_rparen | ']'
|
2220
2221
|
=> {
|
2221
2222
|
emit_table(PUNCTUATION)
|
2222
|
-
|
2223
|
+
|
2224
|
+
@cond.lexpop
|
2225
|
+
if @version < 24
|
2226
|
+
@cmdarg.lexpop
|
2227
|
+
else
|
2228
|
+
@cmdarg.pop
|
2229
|
+
end
|
2223
2230
|
|
2224
2231
|
if tok == '}'.freeze
|
2225
2232
|
fnext expr_endarg;
|
data/lib/parser/lexer/literal.rb
CHANGED
data/lib/parser/source/buffer.rb
CHANGED
@@ -63,7 +63,7 @@ module Parser
|
|
63
63
|
encoding_line = first_line
|
64
64
|
end
|
65
65
|
|
66
|
-
return nil if encoding_line[0] != '#'
|
66
|
+
return nil if encoding_line.nil? || encoding_line[0] != '#'
|
67
67
|
|
68
68
|
if (result = ENCODING_RE.match(encoding_line))
|
69
69
|
Encoding.find(result[3] || result[4] || result[6])
|
@@ -103,7 +103,7 @@ module Parser
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def initialize(name, first_line = 1)
|
106
|
-
@name = name
|
106
|
+
@name = name.to_s
|
107
107
|
@source = nil
|
108
108
|
@first_line = first_line
|
109
109
|
|
@@ -17,7 +17,7 @@ module Parser
|
|
17
17
|
# - The TreeRewriter policy closest to Rewriter's behavior is:
|
18
18
|
# different_replacements: :raise,
|
19
19
|
# swallowed_insertions: :raise,
|
20
|
-
#
|
20
|
+
# crossing_deletions: :accept
|
21
21
|
#
|
22
22
|
# @!attribute [r] source_buffer
|
23
23
|
# @return [Source::Buffer]
|
@@ -273,7 +273,7 @@ module Parser
|
|
273
273
|
|
274
274
|
def check_range_validity(range)
|
275
275
|
if range.begin_pos < 0 || range.end_pos > @source_buffer.source.size
|
276
|
-
raise IndexError, "The range #{
|
276
|
+
raise IndexError, "The range #{range} is outside the bounds of the source"
|
277
277
|
end
|
278
278
|
range
|
279
279
|
end
|
data/lib/parser/version.rb
CHANGED
data/parser.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_dependency 'ast', '~> 2.4.0'
|
37
37
|
|
38
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
39
39
|
spec.add_development_dependency 'rake', '~> 10.0'
|
40
40
|
spec.add_development_dependency 'racc', '= 1.4.14'
|
41
41
|
spec.add_development_dependency 'cliver', '~> 0.3.2'
|
data/test/test_encoding.rb
CHANGED
data/test/test_parser.rb
CHANGED
@@ -1804,6 +1804,14 @@ class TestParser < Minitest::Test
|
|
1804
1804
|
assert_parses(
|
1805
1805
|
s(:def, :until, s(:args), nil),
|
1806
1806
|
%q{def until; end})
|
1807
|
+
|
1808
|
+
assert_parses(
|
1809
|
+
s(:def, :BEGIN, s(:args), nil),
|
1810
|
+
%q{def BEGIN; end})
|
1811
|
+
|
1812
|
+
assert_parses(
|
1813
|
+
s(:def, :END, s(:args), nil),
|
1814
|
+
%q{def END; end})
|
1807
1815
|
end
|
1808
1816
|
|
1809
1817
|
def test_defs
|
@@ -5272,7 +5280,7 @@ class TestParser < Minitest::Test
|
|
5272
5280
|
def test_bom
|
5273
5281
|
assert_parses(
|
5274
5282
|
s(:int, 1),
|
5275
|
-
%Q{\xef\xbb\xbf1}.
|
5283
|
+
%Q{\xef\xbb\xbf1}.b,
|
5276
5284
|
%q{},
|
5277
5285
|
%w(1.9 2.0 2.1))
|
5278
5286
|
end
|
@@ -5284,8 +5292,7 @@ class TestParser < Minitest::Test
|
|
5284
5292
|
s(:send, nil, :puts, s(:lvar, :"проверка"))),
|
5285
5293
|
%Q{# coding:koi8-r
|
5286
5294
|
\xd0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 = 42
|
5287
|
-
puts \xd0\xd2\xcf\xd7\xc5\xd2\xcb\xc1}.
|
5288
|
-
force_encoding(Encoding::BINARY),
|
5295
|
+
puts \xd0\xd2\xcf\xd7\xc5\xd2\xcb\xc1}.b,
|
5289
5296
|
%q{},
|
5290
5297
|
%w(1.9 2.0 2.1))
|
5291
5298
|
end
|
@@ -6767,6 +6774,16 @@ class TestParser < Minitest::Test
|
|
6767
6774
|
%q{m [] do end},
|
6768
6775
|
%q{},
|
6769
6776
|
ALL_VERSIONS)
|
6777
|
+
|
6778
|
+
assert_parses(
|
6779
|
+
s(:block,
|
6780
|
+
s(:send, nil, :m,
|
6781
|
+
s(:array),
|
6782
|
+
s(:int, 1)),
|
6783
|
+
s(:args), nil),
|
6784
|
+
%q{m [], 1 do end},
|
6785
|
+
%q{},
|
6786
|
+
ALL_VERSIONS)
|
6770
6787
|
end
|
6771
6788
|
|
6772
6789
|
def test_bug_435
|
data/test/test_source_buffer.rb
CHANGED
@@ -8,6 +8,12 @@ class TestSourceBuffer < Minitest::Test
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_initialize
|
11
|
+
buffer = Parser::Source::Buffer.new(nil)
|
12
|
+
assert_equal '', buffer.name
|
13
|
+
|
14
|
+
buffer = Parser::Source::Buffer.new(Pathname('a/b'))
|
15
|
+
assert_equal 'a/b', buffer.name
|
16
|
+
|
11
17
|
buffer = Parser::Source::Buffer.new('(string)')
|
12
18
|
assert_equal '(string)', buffer.name
|
13
19
|
assert_equal 1, buffer.first_line
|
@@ -126,15 +126,6 @@ DIAGNOSTIC
|
|
126
126
|
DIAGNOSTIC
|
127
127
|
end
|
128
128
|
|
129
|
-
def test_multiple_actions
|
130
|
-
assert_actions_result 'puts({:hello => [:everybody]})',
|
131
|
-
[:replace, @comma_space, ' => '],
|
132
|
-
[:wrap, @hello.join(@world), '{', '}'],
|
133
|
-
[:replace, @world, ':everybody'],
|
134
|
-
[:wrap, @world, '[', ']']
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
129
|
def test_multiple_actions
|
139
130
|
assert_actions_result 'puts({:hello => [:everybody]})',
|
140
131
|
[:replace, @comma_space, ' => '],
|
@@ -174,4 +165,9 @@ DIAGNOSTIC
|
|
174
165
|
(rewriter):1: ^~~~~ ~~~~
|
175
166
|
DIAGNOSTIC
|
176
167
|
end
|
168
|
+
|
169
|
+
def test_out_of_range_ranges
|
170
|
+
rewriter = Parser::Source::TreeRewriter.new(@buf)
|
171
|
+
assert_raises(IndexError) { rewriter.insert_before(range(0, 100), 'hola') }
|
172
|
+
end
|
177
173
|
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.0.
|
4
|
+
version: 2.5.0.3
|
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-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.15'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.15'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|