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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -6
  3. data/CHANGELOG.md +35 -1
  4. data/Gemfile +2 -0
  5. data/README.md +1 -2
  6. data/Rakefile +2 -1
  7. data/bin/ruby-parse +2 -1
  8. data/bin/ruby-rewrite +2 -1
  9. data/lib/gauntlet_parser.rb +2 -0
  10. data/lib/parser.rb +16 -17
  11. data/lib/parser/all.rb +2 -0
  12. data/lib/parser/ast/node.rb +2 -0
  13. data/lib/parser/ast/processor.rb +2 -0
  14. data/lib/parser/base.rb +6 -12
  15. data/lib/parser/builders/default.rb +28 -47
  16. data/lib/parser/clobbering_error.rb +2 -0
  17. data/lib/parser/context.rb +42 -0
  18. data/lib/parser/current.rb +4 -20
  19. data/lib/parser/deprecation.rb +13 -0
  20. data/lib/parser/diagnostic.rb +3 -3
  21. data/lib/parser/diagnostic/engine.rb +2 -0
  22. data/lib/parser/lexer.rl +122 -60
  23. data/lib/parser/lexer/dedenter.rb +2 -0
  24. data/lib/parser/lexer/explanation.rb +2 -0
  25. data/lib/parser/lexer/literal.rb +4 -9
  26. data/lib/parser/lexer/stack_state.rb +4 -1
  27. data/lib/parser/macruby.y +32 -17
  28. data/lib/parser/messages.rb +14 -0
  29. data/lib/parser/meta.rb +2 -0
  30. data/lib/parser/rewriter.rb +30 -44
  31. data/lib/parser/ruby18.y +20 -13
  32. data/lib/parser/ruby19.y +32 -17
  33. data/lib/parser/ruby20.y +33 -18
  34. data/lib/parser/ruby21.y +32 -17
  35. data/lib/parser/ruby22.y +32 -17
  36. data/lib/parser/ruby23.y +32 -17
  37. data/lib/parser/ruby24.y +63 -46
  38. data/lib/parser/ruby25.y +72 -48
  39. data/lib/parser/rubymotion.y +33 -18
  40. data/lib/parser/runner.rb +4 -7
  41. data/lib/parser/runner/ruby_parse.rb +10 -0
  42. data/lib/parser/runner/ruby_rewrite.rb +2 -0
  43. data/lib/parser/source/buffer.rb +19 -24
  44. data/lib/parser/source/comment.rb +2 -0
  45. data/lib/parser/source/comment/associator.rb +2 -0
  46. data/lib/parser/source/map.rb +2 -0
  47. data/lib/parser/source/map/collection.rb +2 -0
  48. data/lib/parser/source/map/condition.rb +2 -0
  49. data/lib/parser/source/map/constant.rb +2 -0
  50. data/lib/parser/source/map/definition.rb +2 -0
  51. data/lib/parser/source/map/for.rb +2 -0
  52. data/lib/parser/source/map/heredoc.rb +2 -0
  53. data/lib/parser/source/map/keyword.rb +2 -0
  54. data/lib/parser/source/map/objc_kwarg.rb +2 -0
  55. data/lib/parser/source/map/operator.rb +2 -0
  56. data/lib/parser/source/map/rescue_body.rb +2 -0
  57. data/lib/parser/source/map/send.rb +2 -0
  58. data/lib/parser/source/map/ternary.rb +2 -0
  59. data/lib/parser/source/map/variable.rb +2 -0
  60. data/lib/parser/source/range.rb +81 -13
  61. data/lib/parser/source/rewriter.rb +48 -10
  62. data/lib/parser/source/rewriter/action.rb +2 -0
  63. data/lib/parser/source/tree_rewriter.rb +301 -0
  64. data/lib/parser/source/tree_rewriter/action.rb +133 -0
  65. data/lib/parser/static_environment.rb +2 -0
  66. data/lib/parser/syntax_error.rb +2 -0
  67. data/lib/parser/tree_rewriter.rb +133 -0
  68. data/lib/parser/version.rb +3 -1
  69. data/parser.gemspec +4 -1
  70. data/test/bug_163/fixtures/input.rb +2 -0
  71. data/test/bug_163/fixtures/output.rb +2 -0
  72. data/test/bug_163/rewriter.rb +2 -0
  73. data/test/helper.rb +7 -7
  74. data/test/parse_helper.rb +57 -10
  75. data/test/racc_coverage_helper.rb +2 -0
  76. data/test/test_base.rb +2 -0
  77. data/test/test_current.rb +2 -4
  78. data/test/test_diagnostic.rb +3 -1
  79. data/test/test_diagnostic_engine.rb +2 -0
  80. data/test/test_encoding.rb +61 -49
  81. data/test/test_lexer.rb +164 -77
  82. data/test/test_lexer_stack_state.rb +2 -0
  83. data/test/test_parse_helper.rb +8 -8
  84. data/test/test_parser.rb +613 -51
  85. data/test/test_runner_rewrite.rb +47 -0
  86. data/test/test_source_buffer.rb +22 -10
  87. data/test/test_source_comment.rb +2 -0
  88. data/test/test_source_comment_associator.rb +2 -0
  89. data/test/test_source_map.rb +2 -0
  90. data/test/test_source_range.rb +92 -45
  91. data/test/test_source_rewriter.rb +3 -1
  92. data/test/test_source_rewriter_action.rb +2 -0
  93. data/test/test_source_tree_rewriter.rb +177 -0
  94. data/test/test_static_environment.rb +2 -0
  95. data/test/using_tree_rewriter/fixtures/input.rb +3 -0
  96. data/test/using_tree_rewriter/fixtures/output.rb +3 -0
  97. data/test/using_tree_rewriter/using_tree_rewriter.rb +9 -0
  98. metadata +21 -10
  99. data/lib/parser/compatibility/ruby1_8.rb +0 -20
  100. data/lib/parser/compatibility/ruby1_9.rb +0 -32
  101. data/test/bug_163/test_runner_rewrite.rb +0 -35
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestStaticEnvironment < Minitest::Test
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ 6 * 7
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ([6] * 7)
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UsingTreeRewriter < Parser::TreeRewriter
4
+ def on_send(node)
5
+ wrap(node.loc.expression, '(', ')')
6
+ wrap(node.children[0].loc.expression, '[', ']')
7
+ super
8
+ end
9
+ 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.4.0.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: 2017-11-13 00:00:00.000000000 Z
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: '2.3'
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: '2.3'
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/compatibility/ruby1_8.rb
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: '0'
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.1
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