ParseTree 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig ADDED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,17 @@
1
+ === 3.0.4 / 2009-06-23
2
+
3
+ * 4 minor enhancements:
4
+
5
+ * Pulled unique.rb from ParseTree to sexp_processor.
6
+ * Switched to minitest
7
+ * UnifiedRuby strips flip2 back down to expected values
8
+ * Updated Rakefile for new hoe
9
+
10
+ * 2 bug fixes:
11
+
12
+ * 1.8.6p287 & 1.8.7 changed flip2 with fixnum start. fixed
13
+ * 1.8.6p287 & 1.8.7 removed the begin node. fixed.
14
+
1
15
  === 3.0.3 / 2009-01-20
2
16
 
3
17
  * 4 bug fixes:
data/Manifest.txt CHANGED
@@ -12,10 +12,8 @@ lib/gauntlet_parsetree.rb
12
12
  lib/parse_tree.rb
13
13
  lib/parse_tree_extensions.rb
14
14
  lib/unified_ruby.rb
15
- lib/unique.rb
16
15
  test/pt_testcase.rb
17
16
  test/something.rb
18
- test/test_all.rb
19
17
  test/test_parse_tree.rb
20
18
  test/test_parse_tree_extensions.rb
21
19
  test/test_unified_ruby.rb
data/Rakefile CHANGED
@@ -8,21 +8,22 @@ Hoe.add_include_dirs("../../RubyInline/dev/lib",
8
8
  "../../ZenTest/dev/lib",
9
9
  "lib")
10
10
 
11
- require './lib/parse_tree.rb'
11
+ Hoe.plugin :seattlerb
12
12
 
13
- Hoe.new("ParseTree", ParseTree::VERSION) do |pt|
14
- pt.rubyforge_name = "parsetree"
13
+ Hoe.spec "ParseTree" do
14
+ developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
15
15
 
16
- pt.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
16
+ clean_globs << File.expand_path("~/.ruby_inline")
17
+ extra_deps << ['RubyInline', '>= 3.7.0']
18
+ extra_deps << ['sexp_processor', '>= 3.0.0']
17
19
 
18
- pt.clean_globs << File.expand_path("~/.ruby_inline")
19
- pt.extra_deps << ['RubyInline', '>= 3.7.0']
20
- pt.extra_deps << ['sexp_processor', '>= 3.0.0']
21
- pt.spec_extras[:require_paths] = proc { |paths| paths << 'test' }
20
+ spec_extras[:require_paths] = proc { |paths| paths << 'test' }
22
21
 
23
- pt.multiruby_skip << "mri_rel_1_9" << "rubinius" << "mri_trunk"
22
+ multiruby_skip << "1.9"
24
23
  end
25
24
 
25
+ task :test => :clean
26
+
26
27
  desc 'Run in gdb'
27
28
  task :debug do
28
29
  puts "RUN: r -d #{Hoe::RUBY_FLAGS} test/test_all.rb #{Hoe::FILTER}"
data/lib/parse_tree.rb CHANGED
@@ -43,7 +43,7 @@ end
43
43
 
44
44
  class RawParseTree
45
45
 
46
- VERSION = '3.0.3'
46
+ VERSION = '3.0.4'
47
47
 
48
48
  ##
49
49
  # Front end translation method.
@@ -570,10 +570,31 @@ again:
570
570
  add_to_parse_tree(self, current, node->nd_2nd, locals);
571
571
  break;
572
572
 
573
- case NODE_DOT2:
574
- case NODE_DOT3:
575
573
  case NODE_FLIP2:
576
574
  case NODE_FLIP3:
575
+ if (nd_type(node->nd_beg) == NODE_LIT) {
576
+ /*
577
+ new somewhere between 1.8.6 p287 to p368 and 1.8.7 p72 to p160.
578
+ [:flip2, [:call, [:lit, 1], :==, [:array, [:gvar, :$.]]],
579
+ */
580
+ VALUE result = rb_ary_new3(1, _sym("call"));
581
+ add_to_parse_tree(self, result, node->nd_beg, locals);
582
+ rb_ary_push(result, _sym("=="));
583
+ rb_ary_push(result, rb_ary_new3(2, _sym("array"),
584
+ rb_ary_new3(2, _sym("gvar"),
585
+ _sym("$."))));
586
+ rb_ary_push(current, result);
587
+ } else {
588
+ add_to_parse_tree(self, current, node->nd_beg, locals);
589
+ }
590
+
591
+
592
+ // add_to_parse_tree(self, current, node->nd_beg, locals);
593
+ add_to_parse_tree(self, current, node->nd_end, locals);
594
+ break;
595
+
596
+ case NODE_DOT2:
597
+ case NODE_DOT3:
577
598
  add_to_parse_tree(self, current, node->nd_beg, locals);
578
599
  add_to_parse_tree(self, current, node->nd_end, locals);
579
600
  break;
@@ -939,15 +960,10 @@ again:
939
960
  case NODE_STR: /* u1 */
940
961
  case NODE_LIT:
941
962
  rb_ary_push(current, node->nd_lit);
942
- if (node->nd_cflag) {
943
- rb_ary_push(current, INT2FIX(node->nd_cflag));
944
- }
945
963
  break;
946
964
 
947
965
  case NODE_MATCH: /* u1 -> [:lit, u1] */
948
- {
949
- rb_ary_push(current, wrap_into_node("lit", node->nd_lit));
950
- }
966
+ rb_ary_push(current, wrap_into_node("lit", node->nd_lit));
951
967
  break;
952
968
 
953
969
  case NODE_NEWLINE:
data/lib/unified_ruby.rb CHANGED
@@ -218,6 +218,21 @@ module UnifiedRuby
218
218
  rewrite_call(exp)
219
219
  end
220
220
 
221
+ def rewrite_flip2(exp)
222
+ # from:
223
+ # s(:flip2,
224
+ # s(:call, s(:lit, 1), :==, s(:arglist, s(:gvar, :$.))),
225
+ # s(:call, s(:lit, 2), :a?, s(:arglist, s(:call, nil, :b, s(:arglist)))))
226
+ # to:
227
+ # s(:flip2,
228
+ # s(:lit, 1),
229
+ # s(:call, s(:lit, 2), :a?, s(:arglist, s(:call, nil, :b, s(:arglist)))))
230
+ exp[1] = exp[1][1] if exp[1][0] == :call && exp[1][1][0] == :lit
231
+ exp
232
+ end
233
+
234
+ alias :rewrite_flip3 :rewrite_flip2
235
+
221
236
  def rewrite_masgn(exp)
222
237
  raise "wtf: #{exp}" unless exp.size == 4 # TODO: remove 2009-01-29
223
238
  t, lhs, lhs_splat, rhs = exp
data/test/pt_testcase.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  $TESTING = true
2
2
 
3
- require 'test/unit/testcase'
3
+ require 'minitest/unit'
4
4
  require 'sexp_processor' # for deep_clone
5
5
 
6
6
  # key:
@@ -32,12 +32,7 @@ class Examples
32
32
  RUBY_VERSION < "1.9"
33
33
  end
34
34
 
35
- class ParseTreeTestCase < Test::Unit::TestCase
36
- unless defined? Mini then
37
- undef_method :default_test rescue nil
38
- alias :refute_nil :assert_not_nil
39
- end
40
-
35
+ class ParseTreeTestCase < MiniTest::Unit::TestCase
41
36
  attr_accessor :processor # to be defined by subclass
42
37
 
43
38
  def setup
@@ -370,8 +365,7 @@ class ParseTreeTestCase < Test::Unit::TestCase
370
365
 
371
366
  add_tests("begin",
372
367
  "Ruby" => "begin\n (1 + 1)\nend",
373
- "RawParseTree" => [:begin,
374
- [:call, [:lit, 1], :+, [:array, [:lit, 1]]]],
368
+ "RawParseTree" => [:call, [:lit, 1], :+, [:array, [:lit, 1]]],
375
369
  "ParseTree" => s(:call, s(:lit, 1), :+,
376
370
  s(:arglist, s(:lit, 1))),
377
371
  "Ruby2Ruby" => "(1 + 1)")
@@ -385,12 +379,11 @@ class ParseTreeTestCase < Test::Unit::TestCase
385
379
 
386
380
  add_tests("begin_rescue_ensure",
387
381
  "Ruby" => "begin\n a\nrescue\n # do nothing\nensure\n # do nothing\nend",
388
- "RawParseTree" => [:begin,
389
- [:ensure,
390
- [:rescue,
391
- [:vcall, :a],
392
- [:resbody, nil]],
393
- [:nil]]],
382
+ "RawParseTree" => [:ensure,
383
+ [:rescue,
384
+ [:vcall, :a],
385
+ [:resbody, nil]],
386
+ [:nil]],
394
387
  "ParseTree" => s(:ensure,
395
388
  s(:rescue,
396
389
  s(:call, nil, :a, s(:arglist)),
@@ -399,11 +392,10 @@ class ParseTreeTestCase < Test::Unit::TestCase
399
392
 
400
393
  add_tests("begin_rescue_ensure_all_empty",
401
394
  "Ruby" => "begin\n # do nothing\nrescue\n # do nothing\nensure\n # do nothing\nend",
402
- "RawParseTree" => [:begin,
403
- [:ensure,
404
- [:rescue,
405
- [:resbody, nil]],
406
- [:nil]]],
395
+ "RawParseTree" => [:ensure,
396
+ [:rescue,
397
+ [:resbody, nil]],
398
+ [:nil]],
407
399
  "ParseTree" => s(:ensure,
408
400
  s(:rescue,
409
401
  s(:resbody, s(:array), nil)),
@@ -412,16 +404,14 @@ class ParseTreeTestCase < Test::Unit::TestCase
412
404
  add_tests("begin_rescue_twice",
413
405
  "Ruby" => "begin\n a\nrescue => mes\n # do nothing\nend\nbegin\n b\nrescue => mes\n # do nothing\nend\n",
414
406
  "RawParseTree" => [:block,
415
- [:begin,
416
- [:rescue,
417
- [:vcall, :a],
418
- [:resbody, nil,
419
- [:lasgn, :mes, [:gvar, :$!]]]]],
420
- [:begin,
421
- [:rescue,
422
- [:vcall, :b],
423
- [:resbody, nil,
424
- [:lasgn, :mes, [:gvar, :$!]]]]]],
407
+ [:rescue,
408
+ [:vcall, :a],
409
+ [:resbody, nil,
410
+ [:lasgn, :mes, [:gvar, :$!]]]],
411
+ [:rescue,
412
+ [:vcall, :b],
413
+ [:resbody, nil,
414
+ [:lasgn, :mes, [:gvar, :$!]]]]],
425
415
  "ParseTree" => s(:block,
426
416
  s(:rescue,
427
417
  s(:call, nil, :a, s(:arglist)),
@@ -441,11 +431,10 @@ class ParseTreeTestCase < Test::Unit::TestCase
441
431
  [:vcall, :a],
442
432
  [:resbody, nil,
443
433
  [:lasgn, :mes, [:gvar, :$!]]]],
444
- [:begin,
445
- [:rescue,
446
- [:vcall, :b],
447
- [:resbody, nil,
448
- [:lasgn, :mes, [:gvar, :$!]]]]]])
434
+ [:rescue,
435
+ [:vcall, :b],
436
+ [:resbody, nil,
437
+ [:lasgn, :mes, [:gvar, :$!]]]]])
449
438
 
450
439
  copy_test_case "begin_rescue_twice", "Ruby"
451
440
  copy_test_case "begin_rescue_twice", "ParseTree"
@@ -665,10 +654,9 @@ class ParseTreeTestCase < Test::Unit::TestCase
665
654
  [:scope,
666
655
  [:block,
667
656
  [:args],
668
- [:begin,
669
- [:rescue,
670
- [:vcall, :b],
671
- [:resbody, nil, [:vcall, :c]]]],
657
+ [:rescue,
658
+ [:vcall, :b],
659
+ [:resbody, nil, [:vcall, :c]]],
672
660
  [:vcall, :d]]]],
673
661
  "ParseTree" => s(:defn, :f,
674
662
  s(:args),
@@ -703,9 +691,8 @@ class ParseTreeTestCase < Test::Unit::TestCase
703
691
  [:block,
704
692
  [:args],
705
693
  [:vcall, :a],
706
- [:begin,
707
- [:rescue, [:vcall, :b],
708
- [:resbody, nil, [:vcall, :c]]]]]]],
694
+ [:rescue, [:vcall, :b],
695
+ [:resbody, nil, [:vcall, :c]]]]]],
709
696
  "ParseTree" => s(:defn, :f,
710
697
  s(:args),
711
698
  s(:scope,
@@ -730,12 +717,11 @@ class ParseTreeTestCase < Test::Unit::TestCase
730
717
  [:block,
731
718
  [:args],
732
719
  [:vcall, :a],
733
- [:begin,
734
- [:rescue,
735
- [:vcall, :b],
736
- [:resbody,
737
- nil,
738
- [:vcall, :c]]]],
720
+ [:rescue,
721
+ [:vcall, :b],
722
+ [:resbody,
723
+ nil,
724
+ [:vcall, :c]]],
739
725
  [:vcall, :d]]]],
740
726
  "ParseTree" => s(:defn, :f, s(:args),
741
727
  s(:scope,
@@ -1422,14 +1408,13 @@ class ParseTreeTestCase < Test::Unit::TestCase
1422
1408
  [:fcall, :assert_block,
1423
1409
  [:array, [:vcall, :full_message]]],
1424
1410
  nil,
1425
- [:begin,
1426
- [:rescue,
1427
- [:yield],
1428
- [:resbody,
1429
- [:array, [:const, :Exception]],
1430
- [:block,
1431
- [:dasgn, :v,
1432
- [:gvar, :$!]], [:break]]]]]]]],
1411
+ [:rescue,
1412
+ [:yield],
1413
+ [:resbody,
1414
+ [:array, [:const, :Exception]],
1415
+ [:block,
1416
+ [:dasgn, :v,
1417
+ [:gvar, :$!]], [:break]]]]]]],
1433
1418
  "ParseTree" => s(:iter,
1434
1419
  s(:call, nil, :a, s(:arglist)),
1435
1420
  nil,
@@ -2170,20 +2155,19 @@ class ParseTreeTestCase < Test::Unit::TestCase
2170
2155
 
2171
2156
  add_tests("ensure",
2172
2157
  "Ruby" => "begin\n (1 + 1)\nrescue SyntaxError => e1\n 2\nrescue Exception => e2\n 3\nelse\n 4\nensure\n 5\nend",
2173
- "RawParseTree" => [:begin,
2174
- [:ensure,
2175
- [:rescue,
2176
- [:call, [:lit, 1], :+, [:array, [:lit, 1]]],
2158
+ "RawParseTree" => [:ensure,
2159
+ [:rescue,
2160
+ [:call, [:lit, 1], :+, [:array, [:lit, 1]]],
2161
+ [:resbody,
2162
+ [:array, [:const, :SyntaxError]],
2163
+ [:block,
2164
+ [:lasgn, :e1, [:gvar, :$!]], [:lit, 2]],
2177
2165
  [:resbody,
2178
- [:array, [:const, :SyntaxError]],
2166
+ [:array, [:const, :Exception]],
2179
2167
  [:block,
2180
- [:lasgn, :e1, [:gvar, :$!]], [:lit, 2]],
2181
- [:resbody,
2182
- [:array, [:const, :Exception]],
2183
- [:block,
2184
- [:lasgn, :e2, [:gvar, :$!]], [:lit, 3]]]],
2185
- [:lit, 4]],
2186
- [:lit, 5]]],
2168
+ [:lasgn, :e2, [:gvar, :$!]], [:lit, 3]]]],
2169
+ [:lit, 4]],
2170
+ [:lit, 5]],
2187
2171
  "ParseTree" => s(:ensure,
2188
2172
  s(:rescue,
2189
2173
  s(:call, s(:lit, 1), :+,
@@ -2339,7 +2323,8 @@ class ParseTreeTestCase < Test::Unit::TestCase
2339
2323
  "Ruby" => "if 1..2.a?(b) then\n nil\nend",
2340
2324
  "RawParseTree" => [:if,
2341
2325
  [:flip2,
2342
- [:lit, 1],
2326
+ [:call, [:lit, 1], :==,
2327
+ [:array, [:gvar, :$.]]],
2343
2328
  [:call, [:lit, 2], :a?,
2344
2329
  [:array, [:vcall, :b]]]],
2345
2330
  [:nil],
@@ -2910,15 +2895,14 @@ class ParseTreeTestCase < Test::Unit::TestCase
2910
2895
  [:iter,
2911
2896
  [:fcall, :c],
2912
2897
  nil,
2913
- [:begin,
2914
- [:rescue,
2915
- [:vcall, :do_stuff],
2916
- [:resbody,
2917
- [:array, [:const, :RuntimeError]],
2918
- [:block,
2919
- [:dasgn_curr, :b, [:gvar, :$!]],
2920
- [:fcall, :puts,
2921
- [:array, [:dvar, :b]]]]]]]]]]]],
2898
+ [:rescue,
2899
+ [:vcall, :do_stuff],
2900
+ [:resbody,
2901
+ [:array, [:const, :RuntimeError]],
2902
+ [:block,
2903
+ [:dasgn_curr, :b, [:gvar, :$!]],
2904
+ [:fcall, :puts,
2905
+ [:array, [:dvar, :b]]]]]]]]]]],
2922
2906
  "ParseTree" => s(:block,
2923
2907
  s(:lasgn, :b, s(:lit, 42)),
2924
2908
  s(:defn, :a,
@@ -3590,14 +3574,13 @@ class ParseTreeTestCase < Test::Unit::TestCase
3590
3574
 
3591
3575
  add_tests("rescue_block_body",
3592
3576
  "Ruby" => "begin\n a\nrescue => e\n c\n d\nend",
3593
- "RawParseTree" => [:begin,
3594
- [:rescue,
3595
- [:vcall, :a],
3596
- [:resbody, nil,
3597
- [:block,
3598
- [:lasgn, :e, [:gvar, :$!]],
3599
- [:vcall, :c],
3600
- [:vcall, :d]]]]],
3577
+ "RawParseTree" => [:rescue,
3578
+ [:vcall, :a],
3579
+ [:resbody, nil,
3580
+ [:block,
3581
+ [:lasgn, :e, [:gvar, :$!]],
3582
+ [:vcall, :c],
3583
+ [:vcall, :d]]]],
3601
3584
  "ParseTree" => s(:rescue,
3602
3585
  s(:call, nil, :a, s(:arglist)),
3603
3586
  s(:resbody,
@@ -3608,15 +3591,14 @@ class ParseTreeTestCase < Test::Unit::TestCase
3608
3591
 
3609
3592
  add_tests("rescue_block_body_3",
3610
3593
  "Ruby" => "begin\n a\nrescue A\n b\nrescue B\n c\nrescue C\n d\nend",
3611
- "RawParseTree" => [:begin,
3612
- [:rescue,
3613
- [:vcall, :a],
3614
- [:resbody, [:array, [:const, :A]],
3615
- [:vcall, :b],
3616
- [:resbody, [:array, [:const, :B]],
3617
- [:vcall, :c],
3618
- [:resbody, [:array, [:const, :C]],
3619
- [:vcall, :d]]]]]],
3594
+ "RawParseTree" => [:rescue,
3595
+ [:vcall, :a],
3596
+ [:resbody, [:array, [:const, :A]],
3597
+ [:vcall, :b],
3598
+ [:resbody, [:array, [:const, :B]],
3599
+ [:vcall, :c],
3600
+ [:resbody, [:array, [:const, :C]],
3601
+ [:vcall, :d]]]]],
3620
3602
  "ParseTree" => s(:rescue,
3621
3603
  s(:call, nil, :a, s(:arglist)),
3622
3604
  s(:resbody, s(:array, s(:const, :A)),
@@ -3628,14 +3610,13 @@ class ParseTreeTestCase < Test::Unit::TestCase
3628
3610
 
3629
3611
  add_tests("rescue_block_body_ivar",
3630
3612
  "Ruby" => "begin\n a\nrescue => @e\n c\n d\nend",
3631
- "RawParseTree" => [:begin,
3632
- [:rescue,
3633
- [:vcall, :a],
3634
- [:resbody, nil,
3635
- [:block,
3636
- [:iasgn, :@e, [:gvar, :$!]],
3637
- [:vcall, :c],
3638
- [:vcall, :d]]]]],
3613
+ "RawParseTree" => [:rescue,
3614
+ [:vcall, :a],
3615
+ [:resbody, nil,
3616
+ [:block,
3617
+ [:iasgn, :@e, [:gvar, :$!]],
3618
+ [:vcall, :c],
3619
+ [:vcall, :d]]]],
3639
3620
  "ParseTree" => s(:rescue,
3640
3621
  s(:call, nil, :a, s(:arglist)),
3641
3622
  s(:resbody,
@@ -3646,20 +3627,18 @@ class ParseTreeTestCase < Test::Unit::TestCase
3646
3627
 
3647
3628
  add_tests("rescue_block_nada",
3648
3629
  "Ruby" => "begin\n blah\nrescue\n # do nothing\nend",
3649
- "RawParseTree" => [:begin,
3650
- [:rescue, [:vcall, :blah], [:resbody, nil]]],
3630
+ "RawParseTree" => [:rescue, [:vcall, :blah], [:resbody, nil]],
3651
3631
  "ParseTree" => s(:rescue,
3652
3632
  s(:call, nil, :blah, s(:arglist)),
3653
3633
  s(:resbody, s(:array), nil)))
3654
3634
 
3655
3635
  add_tests("rescue_exceptions",
3656
3636
  "Ruby" => "begin\n blah\nrescue RuntimeError => r\n # do nothing\nend",
3657
- "RawParseTree" => [:begin,
3658
- [:rescue,
3659
- [:vcall, :blah],
3660
- [:resbody,
3661
- [:array, [:const, :RuntimeError]],
3662
- [:lasgn, :r, [:gvar, :$!]]]]],
3637
+ "RawParseTree" => [:rescue,
3638
+ [:vcall, :blah],
3639
+ [:resbody,
3640
+ [:array, [:const, :RuntimeError]],
3641
+ [:lasgn, :r, [:gvar, :$!]]]],
3663
3642
  "ParseTree" => s(:rescue,
3664
3643
  s(:call, nil, :blah, s(:arglist)),
3665
3644
  s(:resbody,
@@ -3671,10 +3650,9 @@ class ParseTreeTestCase < Test::Unit::TestCase
3671
3650
 
3672
3651
  add_tests("rescue_iasgn_var_empty",
3673
3652
  "Ruby" => "begin\n 1\nrescue => @e\n # do nothing\nend",
3674
- "RawParseTree" => [:begin,
3675
- [:rescue,
3676
- [:lit, 1],
3677
- [:resbody, nil, [:iasgn, :@e, [:gvar, :$!]]]]],
3653
+ "RawParseTree" => [:rescue,
3654
+ [:lit, 1],
3655
+ [:resbody, nil, [:iasgn, :@e, [:gvar, :$!]]]],
3678
3656
  "ParseTree" => s(:rescue,
3679
3657
  s(:lit, 1),
3680
3658
  s(:resbody,
@@ -3683,10 +3661,9 @@ class ParseTreeTestCase < Test::Unit::TestCase
3683
3661
 
3684
3662
  add_tests("rescue_lasgn",
3685
3663
  "Ruby" => "begin\n 1\nrescue\n var = 2\nend",
3686
- "RawParseTree" => [:begin,
3687
- [:rescue,
3688
- [:lit, 1],
3689
- [:resbody, nil, [:lasgn, :var, [:lit, 2]]]]],
3664
+ "RawParseTree" => [:rescue,
3665
+ [:lit, 1],
3666
+ [:resbody, nil, [:lasgn, :var, [:lit, 2]]]],
3690
3667
  "ParseTree" => s(:rescue,
3691
3668
  s(:lit, 1),
3692
3669
  s(:resbody,
@@ -3696,13 +3673,12 @@ class ParseTreeTestCase < Test::Unit::TestCase
3696
3673
 
3697
3674
  add_tests("rescue_lasgn_var",
3698
3675
  "Ruby" => "begin\n 1\nrescue => e\n var = 2\nend",
3699
- "RawParseTree" => [:begin,
3700
- [:rescue,
3701
- [:lit, 1],
3702
- [:resbody, nil,
3703
- [:block,
3704
- [:lasgn, :e, [:gvar, :$!]],
3705
- [:lasgn, :var, [:lit, 2]]]]]],
3676
+ "RawParseTree" => [:rescue,
3677
+ [:lit, 1],
3678
+ [:resbody, nil,
3679
+ [:block,
3680
+ [:lasgn, :e, [:gvar, :$!]],
3681
+ [:lasgn, :var, [:lit, 2]]]]],
3706
3682
  "ParseTree" => s(:rescue,
3707
3683
  s(:lit, 1),
3708
3684
  s(:resbody,
@@ -3711,10 +3687,9 @@ class ParseTreeTestCase < Test::Unit::TestCase
3711
3687
 
3712
3688
  add_tests("rescue_lasgn_var_empty",
3713
3689
  "Ruby" => "begin\n 1\nrescue => e\n # do nothing\nend",
3714
- "RawParseTree" => [:begin,
3715
- [:rescue,
3716
- [:lit, 1],
3717
- [:resbody, nil, [:lasgn, :e, [:gvar, :$!]]]]],
3690
+ "RawParseTree" => [:rescue,
3691
+ [:lit, 1],
3692
+ [:resbody, nil, [:lasgn, :e, [:gvar, :$!]]]],
3718
3693
  "ParseTree" => s(:rescue,
3719
3694
  s(:lit, 1),
3720
3695
  s(:resbody,
@@ -8,7 +8,7 @@ if test ?d, dir then
8
8
  FileUtils.rm_r dir, :force => true
9
9
  end
10
10
 
11
- require 'test/unit'
11
+ require 'minitest/autorun'
12
12
  require 'parse_tree'
13
13
  require 'pt_testcase'
14
14
  require 'test/something'
@@ -105,90 +105,90 @@ class TestRawParseTree < ParseTreeTestCase
105
105
  @@missing = [nil]
106
106
 
107
107
  @@opt_args = [:defn, :opt_args,
108
- [:scope,
109
- [:block,
110
- [:args, :arg1, :arg2, :"*args", [:block, [:lasgn, :arg2, [:lit, 42]]]],
111
- [:lasgn, :arg3,
112
- [:call,
113
- [:call,
114
- [:lvar, :arg1],
115
- :*,
116
- [:array, [:lvar, :arg2]]],
117
- :*,
118
- [:array, [:lit, 7]]]],
119
- [:fcall, :puts, [:array, [:call, [:lvar, :arg3], :to_s]]],
120
- [:return,
121
- [:str, "foo"]]]]]
108
+ [:scope,
109
+ [:block,
110
+ [:args, :arg1, :arg2, :"*args",
111
+ [:block, [:lasgn, :arg2, [:lit, 42]]]],
112
+ [:lasgn, :arg3,
113
+ [:call,
114
+ [:call,
115
+ [:lvar, :arg1],
116
+ :*,
117
+ [:array, [:lvar, :arg2]]],
118
+ :*,
119
+ [:array, [:lit, 7]]]],
120
+ [:fcall, :puts, [:array, [:call, [:lvar, :arg3], :to_s]]],
121
+ [:return,
122
+ [:str, "foo"]]]]]
122
123
 
123
124
  @@multi_args = [:defn, :multi_args,
124
- [:scope,
125
- [:block,
126
- [:args, :arg1, :arg2],
127
- [:lasgn, :arg3,
128
- [:call,
129
- [:call,
130
- [:lvar, :arg1],
131
- :*,
132
- [:array, [:lvar, :arg2]]],
133
- :*,
134
- [:array, [:lit, 7]]]],
135
- [:fcall, :puts, [:array, [:call, [:lvar, :arg3], :to_s]]],
136
- [:return,
137
- [:str, "foo"]]]]]
125
+ [:scope,
126
+ [:block,
127
+ [:args, :arg1, :arg2],
128
+ [:lasgn, :arg3,
129
+ [:call,
130
+ [:call,
131
+ [:lvar, :arg1],
132
+ :*,
133
+ [:array, [:lvar, :arg2]]],
134
+ :*,
135
+ [:array, [:lit, 7]]]],
136
+ [:fcall, :puts, [:array, [:call, [:lvar, :arg3], :to_s]]],
137
+ [:return,
138
+ [:str, "foo"]]]]]
138
139
 
139
140
  @@unknown_args = [:defn, :unknown_args,
140
- [:scope,
141
- [:block,
142
- [:args, :arg1, :arg2],
143
- [:return, [:lvar, :arg1]]]]]
141
+ [:scope,
142
+ [:block,
143
+ [:args, :arg1, :arg2],
144
+ [:return, [:lvar, :arg1]]]]]
144
145
 
145
146
  @@bbegin = [:defn, :bbegin,
146
- [:scope,
147
- [:block,
148
- [:args],
149
- [:begin,
150
- [:ensure,
151
- [:rescue,
152
- [:lit, 1],
153
- [:resbody,
154
- [:array, [:const, :SyntaxError]],
155
- [:block, [:lasgn, :e1, [:gvar, :$!]], [:lit, 2]],
156
- [:resbody,
157
- [:array, [:const, :Exception]],
158
- [:block, [:lasgn, :e2, [:gvar, :$!]], [:lit, 3]]]],
159
- [:lit, 4]],
160
- [:lit, 5]]]]]]
147
+ [:scope,
148
+ [:block,
149
+ [:args],
150
+ [:ensure,
151
+ [:rescue,
152
+ [:lit, 1],
153
+ [:resbody,
154
+ [:array, [:const, :SyntaxError]],
155
+ [:block, [:lasgn, :e1, [:gvar, :$!]], [:lit, 2]],
156
+ [:resbody,
157
+ [:array, [:const, :Exception]],
158
+ [:block, [:lasgn, :e2, [:gvar, :$!]], [:lit, 3]]]],
159
+ [:lit, 4]],
160
+ [:lit, 5]]]]]
161
+
161
162
  @@bbegin_no_exception = [:defn, :bbegin_no_exception,
162
- [:scope,
163
- [:block,
164
- [:args],
165
- [:begin,
166
- [:rescue,
167
- [:lit, 5],
168
- [:resbody, nil, [:lit, 6]]]]]]]
163
+ [:scope,
164
+ [:block,
165
+ [:args],
166
+ [:rescue,
167
+ [:lit, 5],
168
+ [:resbody, nil, [:lit, 6]]]]]]
169
169
 
170
170
  @@determine_args = [:defn, :determine_args,
171
- [:scope,
172
- [:block,
173
- [:args],
174
- [:call,
175
- [:lit, 5],
176
- :==,
177
- [:array,
178
- [:fcall,
179
- :unknown_args,
180
- [:array, [:lit, 4], [:str, "known"]]]]]]]]
171
+ [:scope,
172
+ [:block,
173
+ [:args],
174
+ [:call,
175
+ [:lit, 5],
176
+ :==,
177
+ [:array,
178
+ [:fcall,
179
+ :unknown_args,
180
+ [:array, [:lit, 4], [:str, "known"]]]]]]]]
181
181
 
182
182
  @@attrasgn = [:defn,
183
- :attrasgn,
184
- [:scope,
185
- [:block,
186
- [:args],
187
- [:attrasgn, [:lit, 42], :method=, [:array, [:vcall, :y]]],
188
- [:attrasgn,
189
- [:self],
190
- :type=,
191
- [:array, [:call, [:vcall, :other], :type]]]]]]
183
+ :attrasgn,
184
+ [:scope,
185
+ [:block,
186
+ [:args],
187
+ [:attrasgn, [:lit, 42], :method=, [:array, [:vcall, :y]]],
188
+ [:attrasgn,
189
+ [:self],
190
+ :type=,
191
+ [:array, [:call, [:vcall, :other], :type]]]]]]
192
192
 
193
193
  @@__all = [:class, :Something, [:const, :Object]]
194
194
 
@@ -1,4 +1,4 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'parse_tree'
3
3
  require 'parse_tree_extensions'
4
4
  require 'tmpdir'
@@ -6,7 +6,7 @@ require 'tmpdir'
6
6
  $: << "../../ruby2ruby/dev/lib" # unoffical dependency - user responsibility
7
7
  require 'ruby2ruby'
8
8
 
9
- class R2RTestCase < Test::Unit::TestCase
9
+ class R2RTestCase < MiniTest::Unit::TestCase
10
10
  def test_proc_to_ruby
11
11
  util_setup_inline
12
12
  block = proc { puts "something" }
@@ -2,13 +2,13 @@
2
2
 
3
3
  $TESTING = true
4
4
 
5
- require 'test/unit' if $0 == __FILE__ unless defined? $ZENTEST and $ZENTEST
5
+ require 'minitest/autorun' if $0 == __FILE__ unless defined? $ZENTEST and $ZENTEST
6
6
  require 'test/unit/testcase'
7
7
  require 'sexp'
8
8
  require 'sexp_processor'
9
9
  require 'unified_ruby'
10
10
 
11
- class TestUnifier < Test::Unit::TestCase
11
+ class TestUnifier < MiniTest::Unit::TestCase
12
12
  def test_pre_fcall
13
13
  u = PreUnifier.new
14
14
 
metadata CHANGED
@@ -1,15 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ParseTree
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
14
+ ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
+ GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
16
+ AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
+ JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
+ b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
19
+ taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
20
+ oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
21
+ GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
22
+ qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
+ gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
+ HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
25
+ AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
26
+ vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
27
+ w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
28
+ l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
29
+ n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
30
+ FBHgymkyj/AOSqKRIpXPhjC6
31
+ -----END CERTIFICATE-----
11
32
 
12
- date: 2009-01-20 00:00:00 -08:00
33
+ date: 2009-06-23 00:00:00 -07:00
13
34
  default_executable:
14
35
  dependencies:
15
36
  - !ruby/object:Gem::Dependency
@@ -40,9 +61,35 @@ dependencies:
40
61
  requirements:
41
62
  - - ">="
42
63
  - !ruby/object:Gem::Version
43
- version: 1.8.2
64
+ version: 2.3.0
44
65
  version:
45
- description: "ParseTree is a C extension (using RubyInline) that extracts the parse tree for an entire class or a specific method and returns it as a s-expression (aka sexp) using ruby's arrays, strings, symbols, and integers. As an example: def conditional1(arg1) if arg1 == 0 then return 1 end return 0 end becomes: [:defn, :conditional1, [:scope, [:block, [:args, :arg1], [:if, [:call, [:lvar, :arg1], :==, [:array, [:lit, 0]]], [:return, [:lit, 1]], nil], [:return, [:lit, 0]]]]]"
66
+ description: |-
67
+ ParseTree is a C extension (using RubyInline) that extracts the parse
68
+ tree for an entire class or a specific method and returns it as a
69
+ s-expression (aka sexp) using ruby's arrays, strings, symbols, and
70
+ integers.
71
+
72
+ As an example:
73
+
74
+ def conditional1(arg1)
75
+ if arg1 == 0 then
76
+ return 1
77
+ end
78
+ return 0
79
+ end
80
+
81
+ becomes:
82
+
83
+ [:defn,
84
+ :conditional1,
85
+ [:scope,
86
+ [:block,
87
+ [:args, :arg1],
88
+ [:if,
89
+ [:call, [:lvar, :arg1], :==, [:array, [:lit, 0]]],
90
+ [:return, [:lit, 1]],
91
+ nil],
92
+ [:return, [:lit, 0]]]]]
46
93
  email:
47
94
  - ryand-ruby@zenspider.com
48
95
  executables:
@@ -71,16 +118,16 @@ files:
71
118
  - lib/parse_tree.rb
72
119
  - lib/parse_tree_extensions.rb
73
120
  - lib/unified_ruby.rb
74
- - lib/unique.rb
75
121
  - test/pt_testcase.rb
76
122
  - test/something.rb
77
- - test/test_all.rb
78
123
  - test/test_parse_tree.rb
79
124
  - test/test_parse_tree_extensions.rb
80
125
  - test/test_unified_ruby.rb
81
126
  - validate.sh
82
127
  has_rdoc: true
83
128
  homepage: http://rubyforge.org/projects/parsetree/
129
+ licenses: []
130
+
84
131
  post_install_message:
85
132
  rdoc_options:
86
133
  - --main
@@ -103,9 +150,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
150
  requirements: []
104
151
 
105
152
  rubyforge_project: parsetree
106
- rubygems_version: 1.3.1
153
+ rubygems_version: 1.3.4
107
154
  signing_key:
108
- specification_version: 2
155
+ specification_version: 3
109
156
  summary: ParseTree is a C extension (using RubyInline) that extracts the parse tree for an entire class or a specific method and returns it as a s-expression (aka sexp) using ruby's arrays, strings, symbols, and integers
110
157
  test_files:
111
- - test/test_all.rb
158
+ - test/test_parse_tree.rb
159
+ - test/test_parse_tree_extensions.rb
160
+ - test/test_unified_ruby.rb
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ =p���J����F[��Ć+��6*�� �?ڴu�"����O��C8 �f �*�Y�!�;]��Ԍ=��H�1��m��+ǫм�8B�wR�r;�TV|*'�����\ˮ����1���B���c�o-֤Λ���x]�_�s)z�@)H�tk��mz��%��{o�H���asƲ�cĚH6j~r3���)� ��R"��:��ZnZ
data/lib/unique.rb DELETED
@@ -1,15 +0,0 @@
1
- ##
2
- # Unique creates unique variable names.
3
-
4
- class Unique
5
- def self.reset # mostly for testing
6
- @@curr = 0
7
- end
8
-
9
- def self.next
10
- @@curr += 1
11
- "temp_#{@@curr}".intern
12
- end
13
-
14
- reset
15
- end
data/test/test_all.rb DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- pat = "test_*.rb"
4
- if File.basename(Dir.pwd) != "test" then
5
- $: << "test"
6
- pat = File.join("test", pat)
7
- end
8
-
9
- Dir.glob(pat).each do |f|
10
- require f
11
- end
12
-
13
- require 'test/unit'