parser 2.4.0.2 → 2.5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/CHANGELOG.md +35 -1
- data/Gemfile +2 -0
- data/README.md +1 -2
- data/Rakefile +2 -1
- data/bin/ruby-parse +2 -1
- data/bin/ruby-rewrite +2 -1
- data/lib/gauntlet_parser.rb +2 -0
- data/lib/parser.rb +16 -17
- data/lib/parser/all.rb +2 -0
- data/lib/parser/ast/node.rb +2 -0
- data/lib/parser/ast/processor.rb +2 -0
- data/lib/parser/base.rb +6 -12
- data/lib/parser/builders/default.rb +28 -47
- data/lib/parser/clobbering_error.rb +2 -0
- data/lib/parser/context.rb +42 -0
- data/lib/parser/current.rb +4 -20
- data/lib/parser/deprecation.rb +13 -0
- data/lib/parser/diagnostic.rb +3 -3
- data/lib/parser/diagnostic/engine.rb +2 -0
- data/lib/parser/lexer.rl +122 -60
- data/lib/parser/lexer/dedenter.rb +2 -0
- data/lib/parser/lexer/explanation.rb +2 -0
- data/lib/parser/lexer/literal.rb +4 -9
- data/lib/parser/lexer/stack_state.rb +4 -1
- data/lib/parser/macruby.y +32 -17
- data/lib/parser/messages.rb +14 -0
- data/lib/parser/meta.rb +2 -0
- data/lib/parser/rewriter.rb +30 -44
- data/lib/parser/ruby18.y +20 -13
- data/lib/parser/ruby19.y +32 -17
- data/lib/parser/ruby20.y +33 -18
- data/lib/parser/ruby21.y +32 -17
- data/lib/parser/ruby22.y +32 -17
- data/lib/parser/ruby23.y +32 -17
- data/lib/parser/ruby24.y +63 -46
- data/lib/parser/ruby25.y +72 -48
- data/lib/parser/rubymotion.y +33 -18
- data/lib/parser/runner.rb +4 -7
- data/lib/parser/runner/ruby_parse.rb +10 -0
- data/lib/parser/runner/ruby_rewrite.rb +2 -0
- data/lib/parser/source/buffer.rb +19 -24
- data/lib/parser/source/comment.rb +2 -0
- data/lib/parser/source/comment/associator.rb +2 -0
- data/lib/parser/source/map.rb +2 -0
- data/lib/parser/source/map/collection.rb +2 -0
- data/lib/parser/source/map/condition.rb +2 -0
- data/lib/parser/source/map/constant.rb +2 -0
- data/lib/parser/source/map/definition.rb +2 -0
- data/lib/parser/source/map/for.rb +2 -0
- data/lib/parser/source/map/heredoc.rb +2 -0
- data/lib/parser/source/map/keyword.rb +2 -0
- data/lib/parser/source/map/objc_kwarg.rb +2 -0
- data/lib/parser/source/map/operator.rb +2 -0
- data/lib/parser/source/map/rescue_body.rb +2 -0
- data/lib/parser/source/map/send.rb +2 -0
- data/lib/parser/source/map/ternary.rb +2 -0
- data/lib/parser/source/map/variable.rb +2 -0
- data/lib/parser/source/range.rb +81 -13
- data/lib/parser/source/rewriter.rb +48 -10
- data/lib/parser/source/rewriter/action.rb +2 -0
- data/lib/parser/source/tree_rewriter.rb +301 -0
- data/lib/parser/source/tree_rewriter/action.rb +133 -0
- data/lib/parser/static_environment.rb +2 -0
- data/lib/parser/syntax_error.rb +2 -0
- data/lib/parser/tree_rewriter.rb +133 -0
- data/lib/parser/version.rb +3 -1
- data/parser.gemspec +4 -1
- data/test/bug_163/fixtures/input.rb +2 -0
- data/test/bug_163/fixtures/output.rb +2 -0
- data/test/bug_163/rewriter.rb +2 -0
- data/test/helper.rb +7 -7
- data/test/parse_helper.rb +57 -10
- data/test/racc_coverage_helper.rb +2 -0
- data/test/test_base.rb +2 -0
- data/test/test_current.rb +2 -4
- data/test/test_diagnostic.rb +3 -1
- data/test/test_diagnostic_engine.rb +2 -0
- data/test/test_encoding.rb +61 -49
- data/test/test_lexer.rb +164 -77
- data/test/test_lexer_stack_state.rb +2 -0
- data/test/test_parse_helper.rb +8 -8
- data/test/test_parser.rb +613 -51
- data/test/test_runner_rewrite.rb +47 -0
- data/test/test_source_buffer.rb +22 -10
- data/test/test_source_comment.rb +2 -0
- data/test/test_source_comment_associator.rb +2 -0
- data/test/test_source_map.rb +2 -0
- data/test/test_source_range.rb +92 -45
- data/test/test_source_rewriter.rb +3 -1
- data/test/test_source_rewriter_action.rb +2 -0
- data/test/test_source_tree_rewriter.rb +177 -0
- data/test/test_static_environment.rb +2 -0
- data/test/using_tree_rewriter/fixtures/input.rb +3 -0
- data/test/using_tree_rewriter/fixtures/output.rb +3 -0
- data/test/using_tree_rewriter/using_tree_rewriter.rb +9 -0
- metadata +21 -10
- data/lib/parser/compatibility/ruby1_8.rb +0 -20
- data/lib/parser/compatibility/ruby1_9.rb +0 -32
- data/test/bug_163/test_runner_rewrite.rb +0 -35
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.
|
4
|
+
version: 2.5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- whitequark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,9 +183,9 @@ files:
|
|
183
183
|
- lib/parser/base.rb
|
184
184
|
- lib/parser/builders/default.rb
|
185
185
|
- lib/parser/clobbering_error.rb
|
186
|
-
- lib/parser/
|
187
|
-
- lib/parser/compatibility/ruby1_9.rb
|
186
|
+
- lib/parser/context.rb
|
188
187
|
- lib/parser/current.rb
|
188
|
+
- lib/parser/deprecation.rb
|
189
189
|
- lib/parser/diagnostic.rb
|
190
190
|
- lib/parser/diagnostic/engine.rb
|
191
191
|
- lib/parser/lexer.rb
|
@@ -240,14 +240,16 @@ files:
|
|
240
240
|
- lib/parser/source/range.rb
|
241
241
|
- lib/parser/source/rewriter.rb
|
242
242
|
- lib/parser/source/rewriter/action.rb
|
243
|
+
- lib/parser/source/tree_rewriter.rb
|
244
|
+
- lib/parser/source/tree_rewriter/action.rb
|
243
245
|
- lib/parser/static_environment.rb
|
244
246
|
- lib/parser/syntax_error.rb
|
247
|
+
- lib/parser/tree_rewriter.rb
|
245
248
|
- lib/parser/version.rb
|
246
249
|
- parser.gemspec
|
247
250
|
- test/bug_163/fixtures/input.rb
|
248
251
|
- test/bug_163/fixtures/output.rb
|
249
252
|
- test/bug_163/rewriter.rb
|
250
|
-
- test/bug_163/test_runner_rewrite.rb
|
251
253
|
- test/helper.rb
|
252
254
|
- test/parse_helper.rb
|
253
255
|
- test/racc_coverage_helper.rb
|
@@ -260,6 +262,7 @@ files:
|
|
260
262
|
- test/test_lexer_stack_state.rb
|
261
263
|
- test/test_parse_helper.rb
|
262
264
|
- test/test_parser.rb
|
265
|
+
- test/test_runner_rewrite.rb
|
263
266
|
- test/test_source_buffer.rb
|
264
267
|
- test/test_source_comment.rb
|
265
268
|
- test/test_source_comment_associator.rb
|
@@ -267,7 +270,11 @@ files:
|
|
267
270
|
- test/test_source_range.rb
|
268
271
|
- test/test_source_rewriter.rb
|
269
272
|
- test/test_source_rewriter_action.rb
|
273
|
+
- test/test_source_tree_rewriter.rb
|
270
274
|
- test/test_static_environment.rb
|
275
|
+
- test/using_tree_rewriter/fixtures/input.rb
|
276
|
+
- test/using_tree_rewriter/fixtures/output.rb
|
277
|
+
- test/using_tree_rewriter/using_tree_rewriter.rb
|
271
278
|
homepage: https://github.com/whitequark/parser
|
272
279
|
licenses:
|
273
280
|
- MIT
|
@@ -280,7 +287,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
287
|
requirements:
|
281
288
|
- - ">="
|
282
289
|
- !ruby/object:Gem::Version
|
283
|
-
version:
|
290
|
+
version: 2.0.0
|
284
291
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
292
|
requirements:
|
286
293
|
- - ">="
|
@@ -288,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
288
295
|
version: '0'
|
289
296
|
requirements: []
|
290
297
|
rubyforge_project:
|
291
|
-
rubygems_version: 2.5.2.
|
298
|
+
rubygems_version: 2.5.2.2
|
292
299
|
signing_key:
|
293
300
|
specification_version: 4
|
294
301
|
summary: A Ruby parser written in pure Ruby.
|
@@ -296,7 +303,6 @@ test_files:
|
|
296
303
|
- test/bug_163/fixtures/input.rb
|
297
304
|
- test/bug_163/fixtures/output.rb
|
298
305
|
- test/bug_163/rewriter.rb
|
299
|
-
- test/bug_163/test_runner_rewrite.rb
|
300
306
|
- test/helper.rb
|
301
307
|
- test/parse_helper.rb
|
302
308
|
- test/racc_coverage_helper.rb
|
@@ -309,6 +315,7 @@ test_files:
|
|
309
315
|
- test/test_lexer_stack_state.rb
|
310
316
|
- test/test_parse_helper.rb
|
311
317
|
- test/test_parser.rb
|
318
|
+
- test/test_runner_rewrite.rb
|
312
319
|
- test/test_source_buffer.rb
|
313
320
|
- test/test_source_comment.rb
|
314
321
|
- test/test_source_comment_associator.rb
|
@@ -316,4 +323,8 @@ test_files:
|
|
316
323
|
- test/test_source_range.rb
|
317
324
|
- test/test_source_rewriter.rb
|
318
325
|
- test/test_source_rewriter_action.rb
|
326
|
+
- test/test_source_tree_rewriter.rb
|
319
327
|
- test/test_static_environment.rb
|
328
|
+
- test/using_tree_rewriter/fixtures/input.rb
|
329
|
+
- test/using_tree_rewriter/fixtures/output.rb
|
330
|
+
- test/using_tree_rewriter/using_tree_rewriter.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# @api public
|
3
|
-
#
|
4
|
-
# This monkeypatch extends Ruby 1.8 {String#%} with an ability
|
5
|
-
# to replace named capture groups, i.e.
|
6
|
-
# `"foo: %{bar}" % { :bar => 10 } # => "foo: 10"`.
|
7
|
-
#
|
8
|
-
class String
|
9
|
-
alias original_percent %
|
10
|
-
|
11
|
-
def %(arg, *args)
|
12
|
-
if arg.is_a?(Hash)
|
13
|
-
gsub(/%\{(\w+)\}/) do
|
14
|
-
arg[$1.to_sym]
|
15
|
-
end
|
16
|
-
else
|
17
|
-
original_percent(arg, *args)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
unless Array.method_defined? :bsearch
|
2
|
-
class Array
|
3
|
-
def bsearch
|
4
|
-
return to_enum(__method__) unless block_given?
|
5
|
-
from = 0
|
6
|
-
to = size - 1
|
7
|
-
satisfied = nil
|
8
|
-
while from <= to
|
9
|
-
midpoint = (from + to).div(2)
|
10
|
-
result = yield(cur = self[midpoint])
|
11
|
-
case result
|
12
|
-
when Numeric
|
13
|
-
return cur if result == 0
|
14
|
-
result = result < 0
|
15
|
-
when true
|
16
|
-
satisfied = cur
|
17
|
-
when nil, false
|
18
|
-
# nothing to do
|
19
|
-
else
|
20
|
-
fail TypeError, "wrong argument type #{result.class} (must be numeric, true, false or nil)"
|
21
|
-
end
|
22
|
-
|
23
|
-
if result
|
24
|
-
to = midpoint - 1
|
25
|
-
else
|
26
|
-
from = midpoint + 1
|
27
|
-
end
|
28
|
-
end
|
29
|
-
satisfied
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'shellwords'
|
4
|
-
|
5
|
-
BASE_DIR = Pathname.new(__FILE__) + '../..'
|
6
|
-
require (BASE_DIR + 'helper').expand_path
|
7
|
-
|
8
|
-
class TestRunnerRewrite < Minitest::Test
|
9
|
-
def setup
|
10
|
-
@ruby_rewrite = BASE_DIR.expand_path + '../bin/ruby-rewrite'
|
11
|
-
@test_dir = BASE_DIR + 'bug_163'
|
12
|
-
@fixtures_dir = @test_dir + 'fixtures'
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_rewriter
|
16
|
-
Dir.mktmpdir("parser", BASE_DIR.expand_path.to_s) do |tmp_dir|
|
17
|
-
tmp_dir = Pathname.new(tmp_dir)
|
18
|
-
sample_file = tmp_dir + 'bug_163.rb'
|
19
|
-
sample_file_expanded = sample_file.expand_path
|
20
|
-
expected_file = @fixtures_dir + 'output.rb'
|
21
|
-
|
22
|
-
FileUtils.cp(@fixtures_dir + 'input.rb', tmp_dir + 'bug_163.rb')
|
23
|
-
FileUtils.cd @test_dir do
|
24
|
-
exit_code = system %Q{
|
25
|
-
#{Shellwords.escape(@ruby_rewrite.to_s)} --modify \
|
26
|
-
-l rewriter.rb \
|
27
|
-
#{Shellwords.escape(sample_file_expanded.to_s)}
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
assert File.read(expected_file.expand_path) == File.read(sample_file),
|
32
|
-
"#{sample_file} should be identical to #{expected_file}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|