ripper-plus 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -91,7 +91,7 @@ Need to be properly resolved. Did you know that, unlike the `label = label` exam
91
91
 
92
92
  Why doesn't y end up `nil` in the default case, as it would if you typed `y = y` into a method definition?
93
93
 
94
- Anyway, ripper-plus turns all method-call `:var_ref` nodes into `:zcall` nodes; the node structure is otherwise unchanged. I believe Ripper should already make this distinction, and it can relatively simply: it simply has to re-implement the existing scope-tracking behavior to the relevant Ripper action routines. Not trivial, but `ripper-plus` does it in a couple hundred lines of Ruby.
94
+ Anyway, ripper-plus turns all method-call `:var_ref` nodes into `:vcall` nodes; the node structure is otherwise unchanged. I believe Ripper should already make this distinction, and it can relatively simply: it simply has to re-implement the existing scope-tracking behavior to the relevant Ripper action routines. Not trivial, but `ripper-plus` does it in a couple hundred lines of Ruby.
95
95
 
96
96
  # Error Handling
97
97
 
@@ -7,7 +7,7 @@ module RipperPlus
7
7
  class DuplicateArgumentError < SyntaxError; end
8
8
  # Transforms a 1.9.2 Ripper AST into a RipperPlus AST. The only
9
9
  # change as a result of this transformation is that the nodes for
10
- # local variable references and zcalls (bareword calls to self)
10
+ # local variable references and vcalls (bareword calls to self)
11
11
  # have different node types:
12
12
  #
13
13
  # def foo(x)
@@ -21,7 +21,7 @@ module RipperPlus
21
21
  # [:@ident, "foo", [1, 4]],
22
22
  # [:paren, [:params, [[:@ident, "x", [1, 8]]], nil, nil, nil, nil]],
23
23
  # [:bodystmt,
24
- # [[:zcall, [:@ident, "y", [2, 2]]],
24
+ # [[:vcall, [:@ident, "y", [2, 2]]],
25
25
  # [:assign,
26
26
  # [:var_field, [:@ident, "y", [3, 2]]],
27
27
  # [:var_ref, [:@ident, "x", [3, 6]]]]],
@@ -77,9 +77,9 @@ module RipperPlus
77
77
  transform_tree(body, scope_stack)
78
78
  when :var_ref
79
79
  # When we reach a :var_ref, we should know everything we need to know
80
- # in order to tell if it should be transformed into a :zcall.
80
+ # in order to tell if it should be transformed into a :vcall.
81
81
  if tree[1][0] == :@ident && !scope_stack.has_variable?(tree[1][1])
82
- tree[0] = :zcall
82
+ tree[0] = :vcall
83
83
  end
84
84
  when :class
85
85
  name, superclass, body = tree[1..3]
@@ -1,8 +1,8 @@
1
1
  module RipperPlus
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 2
5
- PATCH = 2
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  BUILD = ''
7
7
 
8
8
  if BUILD.empty?
@@ -1,8 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe RipperPlus::Transformer do
4
- describe 'zcall detection' do
5
- it 'should transform a simple zcall in a method' do
4
+ describe 'vcall detection' do
5
+ it 'should transform a simple vcall in a method' do
6
6
  input_tree =
7
7
  [:program,
8
8
  [[:def,
@@ -22,7 +22,7 @@ describe RipperPlus::Transformer do
22
22
  [:paren, [:params, [[:@ident, "x", [1, 8]]], nil, nil, nil, nil]],
23
23
  [:bodystmt,
24
24
  [[:void_stmt],
25
- [:zcall, [:@ident, "y", [1, 12]]],
25
+ [:vcall, [:@ident, "y", [1, 12]]],
26
26
  [:assign,
27
27
  [:var_field, [:@ident, "y", [1, 15]]],
28
28
  [:var_ref, [:@ident, "x", [1, 19]]]]],
@@ -51,7 +51,7 @@ describe RipperPlus::Transformer do
51
51
  [:paren,
52
52
  [:params,
53
53
  [[:@ident, "x", [1, 8]]],
54
- [[[:@ident, "y", [1, 11]], [:zcall, [:@ident, "z", [1, 13]]]],
54
+ [[[:@ident, "y", [1, 11]], [:vcall, [:@ident, "z", [1, 13]]]],
55
55
  [[:@ident, "z", [1, 16]], [:var_ref, [:@ident, "y", [1, 18]]]]],
56
56
  nil,
57
57
  nil,
@@ -93,7 +93,7 @@ describe RipperPlus::Transformer do
93
93
  [:params,
94
94
  [[:@ident, "x", [1, 10]]],
95
95
  [[[:@ident, "y", [1, 13]], [:var_ref, [:@ident, "x", [1, 15]]]],
96
- [[:@ident, "z", [1, 18]], [:zcall, [:@ident, "a", [1, 20]]]]],
96
+ [[:@ident, "z", [1, 18]], [:vcall, [:@ident, "a", [1, 20]]]]],
97
97
  [:rest_param, [:@ident, "a", [1, 24]]],
98
98
  nil,
99
99
  nil],
@@ -122,7 +122,7 @@ describe RipperPlus::Transformer do
122
122
  output_tree =
123
123
  [:program,
124
124
  [[:defs,
125
- [:zcall, [:@ident, "foo", [1, 4]]],
125
+ [:vcall, [:@ident, "foo", [1, 4]]],
126
126
  [:@period, ".", [1, 7]],
127
127
  [:@ident, "silly", [1, 8]],
128
128
  [:paren, [:params, nil, nil, nil, nil, nil]],
@@ -188,7 +188,7 @@ describe RipperPlus::Transformer do
188
188
  [:arg_paren,
189
189
  [:args_add_block,
190
190
  [[:var_ref, [:@ident, "a", [1, 30]]],
191
- [:zcall, [:@ident, "c", [1, 33]]],
191
+ [:vcall, [:@ident, "c", [1, 33]]],
192
192
  [:var_ref, [:@ident, "d", [1, 36]]]],
193
193
  false]]]]]]
194
194
  input_tree.should transform_to(output_tree)
@@ -241,8 +241,8 @@ describe RipperPlus::Transformer do
241
241
  [:var_ref, [:@ident, "c", [1, 36]]],
242
242
  [:var_ref, [:@ident, "d", [1, 39]]],
243
243
  [:var_ref, [:@ident, "e", [1, 42]]],
244
- [:zcall, [:@ident, "f", [1, 45]]],
245
- [:zcall, [:@ident, "g", [1, 48]]]],
244
+ [:vcall, [:@ident, "f", [1, 45]]],
245
+ [:vcall, [:@ident, "g", [1, 48]]]],
246
246
  false]]],
247
247
  [[:void_stmt]]]]]
248
248
  input_tree.should transform_to(output_tree)
@@ -286,7 +286,7 @@ describe RipperPlus::Transformer do
286
286
  [:params,
287
287
  [[:@ident, "a", [1, 7]]],
288
288
  [[[:@ident, "b", [1, 10]], [:var_ref, [:@ident, "a", [1, 12]]]],
289
- [[:@ident, "c", [1, 15]], [:zcall, [:@ident, "d", [1, 17]]]]],
289
+ [[:@ident, "c", [1, 15]], [:vcall, [:@ident, "d", [1, 17]]]]],
290
290
  [:rest_param, [:@ident, "rest", [1, 21]]],
291
291
  nil,
292
292
  nil]],
@@ -301,10 +301,10 @@ describe RipperPlus::Transformer do
301
301
  :*,
302
302
  [:var_ref, [:@ident, "c", [1, 38]]]],
303
303
  :*,
304
- [:zcall, [:@ident, "d", [1, 42]]]]]],
304
+ [:vcall, [:@ident, "d", [1, 42]]]]]],
305
305
  :+,
306
306
  [:var_ref, [:@ident, "rest", [1, 47]]]]]]],
307
- [:zcall, [:@ident, "a", [1, 55]]]]]
307
+ [:vcall, [:@ident, "a", [1, 55]]]]]
308
308
  input_tree.should transform_to output_tree
309
309
  end
310
310
 
@@ -360,7 +360,7 @@ describe RipperPlus::Transformer do
360
360
  [[:mlhs_paren, [:@ident, "z", [1, 26]]],
361
361
  [:mlhs_paren, [:@ident, "a", [1, 29]]]]]],
362
362
  [[[:@ident, "k", [1, 33]], [:var_ref, [:@ident, "z", [1, 37]]]],
363
- [[:@ident, "j", [1, 40]], [:zcall, [:@ident, "d", [1, 44]]]]],
363
+ [[:@ident, "j", [1, 40]], [:vcall, [:@ident, "d", [1, 44]]]]],
364
364
  [:rest_param, [:@ident, "r", [1, 48]]],
365
365
  nil,
366
366
  [:blockarg, [:@ident, "blk", [1, 52]]]],
@@ -377,7 +377,7 @@ describe RipperPlus::Transformer do
377
377
  [:var_ref, [:@ident, "r", [1, 84]]],
378
378
  [:var_ref, [:@ident, "blk", [1, 87]]],
379
379
  [:var_ref, [:@ident, "local", [1, 92]]],
380
- [:zcall, [:@ident, "foo", [1, 99]]]],
380
+ [:vcall, [:@ident, "foo", [1, 99]]]],
381
381
  false]]]]]]]
382
382
  input_tree.should transform_to(output_tree)
383
383
  end
@@ -411,8 +411,8 @@ describe RipperPlus::Transformer do
411
411
  [:var_ref, [:@ident, "y", [1, 28]]],
412
412
  [:var_ref, [:@ident, "z", [1, 30]]]]]],
413
413
  [:var_ref, [:@ident, "x", [1, 36]]],
414
- [:zcall, [:@ident, "y", [1, 39]]],
415
- [:zcall, [:@ident, "z", [1, 42]]]]]
414
+ [:vcall, [:@ident, "y", [1, 39]]],
415
+ [:vcall, [:@ident, "z", [1, 42]]]]]
416
416
  input_tree.should transform_to(output_tree)
417
417
  end
418
418
 
@@ -431,7 +431,7 @@ describe RipperPlus::Transformer do
431
431
  [:class,
432
432
  [:const_ref, [:@const, "Foo", [1, 13]]],
433
433
  nil,
434
- [:bodystmt, [[:zcall, [:@ident, "x", [1, 18]]]], nil, nil, nil]],
434
+ [:bodystmt, [[:vcall, [:@ident, "x", [1, 18]]]], nil, nil, nil]],
435
435
  [:var_ref, [:@ident, "x", [1, 26]]]]]
436
436
  input_tree.should transform_to(output_tree)
437
437
  end
@@ -454,7 +454,7 @@ describe RipperPlus::Transformer do
454
454
  [:class,
455
455
  [:const_ref, [:@const, "A", [1, 18]]],
456
456
  [:var_ref, [:@ident, "x", [1, 22]]],
457
- [:bodystmt, [[:zcall, [:@ident, "x", [1, 25]]]], nil, nil, nil]]]]
457
+ [:bodystmt, [[:vcall, [:@ident, "x", [1, 25]]]], nil, nil, nil]]]]
458
458
  input_tree.should transform_to output_tree
459
459
  end
460
460
 
@@ -476,7 +476,7 @@ describe RipperPlus::Transformer do
476
476
  [:module,
477
477
  [:const_ref, [:@const, "Foo", [1, 14]]],
478
478
  [:bodystmt,
479
- [[:void_stmt], [:zcall, [:@ident, "x", [1, 19]]]],
479
+ [[:void_stmt], [:vcall, [:@ident, "x", [1, 19]]]],
480
480
  nil,
481
481
  nil,
482
482
  nil]],
@@ -496,7 +496,7 @@ describe RipperPlus::Transformer do
496
496
  [[:assign, [:var_field, [:@ident, "x", [1, 0]]], [:@int, "5", [1, 4]]],
497
497
  [:sclass,
498
498
  [:var_ref, [:@const, "String", [1, 16]]],
499
- [:bodystmt, [[:zcall, [:@ident, "x", [1, 24]]]], nil, nil, nil]]]]
499
+ [:bodystmt, [[:vcall, [:@ident, "x", [1, 24]]]], nil, nil, nil]]]]
500
500
  input_tree.should transform_to output_tree
501
501
  end
502
502
 
@@ -512,7 +512,7 @@ describe RipperPlus::Transformer do
512
512
  input_tree.should transform_to input_tree
513
513
  end
514
514
 
515
- it 'refers to the enclosing environment to determine the singleton to open - resulting in zcall' do
515
+ it 'refers to the enclosing environment to determine the singleton to open - resulting in vcall' do
516
516
  input_tree =
517
517
  [:program,
518
518
  [[:sclass,
@@ -521,7 +521,7 @@ describe RipperPlus::Transformer do
521
521
  output_tree =
522
522
  [:program,
523
523
  [[:sclass,
524
- [:zcall, [:@ident, "x", [1, 19]]],
524
+ [:vcall, [:@ident, "x", [1, 19]]],
525
525
  [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]
526
526
  input_tree.should transform_to output_tree
527
527
  end
@@ -639,18 +639,18 @@ describe RipperPlus::Transformer do
639
639
  nil,
640
640
  [[:command,
641
641
  [:@ident, "p", [1, 48]],
642
- [:args_add_block, [[:zcall, [:@ident, "err", [1, 50]]]], false]]],
642
+ [:args_add_block, [[:vcall, [:@ident, "err", [1, 50]]]], false]]],
643
643
  nil],
644
644
  [:else,
645
645
  [[:void_stmt],
646
646
  [:command,
647
647
  [:@ident, "p", [1, 61]],
648
- [:args_add_block, [[:zcall, [:@ident, "err", [1, 63]]]], false]]]],
648
+ [:args_add_block, [[:vcall, [:@ident, "err", [1, 63]]]], false]]]],
649
649
  [:ensure,
650
650
  [[:void_stmt],
651
651
  [:command,
652
652
  [:@ident, "p", [1, 76]],
653
- [:args_add_block, [[:zcall, [:@ident, "err", [1, 78]]]], false]]]]]]]]
653
+ [:args_add_block, [[:vcall, [:@ident, "err", [1, 78]]]], false]]]]]]]]
654
654
  input_tree.should transform_to output_tree
655
655
  end
656
656
 
@@ -691,7 +691,7 @@ describe RipperPlus::Transformer do
691
691
  [:command,
692
692
  [:@ident, "p", [1, 38]],
693
693
  [:args_add_block, [[:var_ref, [:@ident, "name", [1, 40]]]], false]],
694
- [:zcall, [:@ident, "named", [1, 46]]]],
694
+ [:vcall, [:@ident, "named", [1, 46]]]],
695
695
  nil,
696
696
  nil,
697
697
  nil]]]]
@@ -730,8 +730,8 @@ describe RipperPlus::Transformer do
730
730
  [[:void_stmt],
731
731
  [:binary,
732
732
  [:paren,
733
- [[:zcall, [:@ident, "foo", [1, 13]]],
734
- [:zcall, [:@ident, "bar", [1, 18]]],
733
+ [[:vcall, [:@ident, "foo", [1, 13]]],
734
+ [:vcall, [:@ident, "bar", [1, 18]]],
735
735
  [:regexp_literal,
736
736
  [[:@tstring_content, "name: (?<name>w+) (?<numba>d+)", [1, 24]]],
737
737
  [:@regexp_end, "/", [1, 54]]]]],
@@ -739,7 +739,7 @@ describe RipperPlus::Transformer do
739
739
  [:var_ref, [:@ident, "a", [1, 60]]]],
740
740
  [:var_ref, [:@ident, "name", [1, 63]]],
741
741
  [:var_ref, [:@ident, "numba", [1, 69]]],
742
- [:zcall, [:@ident, "number", [1, 76]]]],
742
+ [:vcall, [:@ident, "number", [1, 76]]]],
743
743
  nil,
744
744
  nil,
745
745
  nil]]]]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ripper-plus
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.2
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Edgar
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-15 00:00:00 Z
13
+ date: 2011-07-09 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- hash: 4245056097260382389
101
+ hash: 393845268359154104
102
102
  segments:
103
103
  - 0
104
104
  version: "0"
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements: []
112
112
 
113
113
  rubyforge_project:
114
- rubygems_version: 1.7.2
114
+ rubygems_version: 1.8.5
115
115
  signing_key:
116
116
  specification_version: 3
117
117
  summary: Parses Ruby code into an improved Ripper AST format