ParseTree 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +14 -0
- data/Manifest.txt +0 -2
- data/Rakefile +10 -9
- data/lib/parse_tree.rb +25 -9
- data/lib/unified_ruby.rb +15 -0
- data/test/pt_testcase.rb +105 -130
- data/test/test_parse_tree.rb +74 -74
- data/test/test_parse_tree_extensions.rb +2 -2
- data/test/test_unified_ruby.rb +2 -2
- metadata +59 -10
- metadata.gz.sig +1 -0
- data/lib/unique.rb +0 -15
- data/test/test_all.rb +0 -13
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
|
-
|
11
|
+
Hoe.plugin :seattlerb
|
12
12
|
|
13
|
-
Hoe.
|
14
|
-
|
13
|
+
Hoe.spec "ParseTree" do
|
14
|
+
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
|
15
15
|
|
16
|
-
|
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
|
-
|
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
|
-
|
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.
|
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 '
|
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 <
|
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" => [:
|
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" => [:
|
389
|
-
[:
|
390
|
-
[:
|
391
|
-
|
392
|
-
|
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" => [:
|
403
|
-
[:
|
404
|
-
[:
|
405
|
-
|
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
|
-
[:
|
416
|
-
[:
|
417
|
-
|
418
|
-
[:
|
419
|
-
|
420
|
-
|
421
|
-
[:
|
422
|
-
[:
|
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
|
-
[:
|
445
|
-
[:
|
446
|
-
|
447
|
-
[:
|
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
|
-
[:
|
669
|
-
[:
|
670
|
-
|
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
|
-
[:
|
707
|
-
[:
|
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
|
-
[:
|
734
|
-
[:
|
735
|
-
|
736
|
-
|
737
|
-
|
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
|
-
[:
|
1426
|
-
[:
|
1427
|
-
|
1428
|
-
[:
|
1429
|
-
|
1430
|
-
[:
|
1431
|
-
[:
|
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" => [:
|
2174
|
-
[:
|
2175
|
-
[:
|
2176
|
-
|
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, :
|
2166
|
+
[:array, [:const, :Exception]],
|
2179
2167
|
[:block,
|
2180
|
-
[:lasgn, :
|
2181
|
-
|
2182
|
-
|
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
|
-
[:
|
2914
|
-
[:
|
2915
|
-
|
2916
|
-
[:
|
2917
|
-
|
2918
|
-
[:
|
2919
|
-
|
2920
|
-
[:
|
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" => [:
|
3594
|
-
[:
|
3595
|
-
|
3596
|
-
[:
|
3597
|
-
[:
|
3598
|
-
|
3599
|
-
|
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" => [:
|
3612
|
-
[:
|
3613
|
-
|
3614
|
-
[:
|
3615
|
-
|
3616
|
-
[:
|
3617
|
-
|
3618
|
-
[:
|
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" => [:
|
3632
|
-
[:
|
3633
|
-
|
3634
|
-
[:
|
3635
|
-
[:
|
3636
|
-
|
3637
|
-
|
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" => [:
|
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" => [:
|
3658
|
-
[:
|
3659
|
-
|
3660
|
-
[:
|
3661
|
-
|
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" => [:
|
3675
|
-
[:
|
3676
|
-
|
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" => [:
|
3687
|
-
[:
|
3688
|
-
|
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" => [:
|
3700
|
-
[:
|
3701
|
-
|
3702
|
-
[:
|
3703
|
-
[:
|
3704
|
-
|
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" => [:
|
3715
|
-
[:
|
3716
|
-
|
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,
|
data/test/test_parse_tree.rb
CHANGED
@@ -8,7 +8,7 @@ if test ?d, dir then
|
|
8
8
|
FileUtils.rm_r dir, :force => true
|
9
9
|
end
|
10
10
|
|
11
|
-
require '
|
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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
141
|
+
[:scope,
|
142
|
+
[:block,
|
143
|
+
[:args, :arg1, :arg2],
|
144
|
+
[:return, [:lvar, :arg1]]]]]
|
144
145
|
|
145
146
|
@@bbegin = [:defn, :bbegin,
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
[:
|
159
|
-
|
160
|
-
|
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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
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
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
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
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
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 '
|
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 <
|
9
|
+
class R2RTestCase < MiniTest::Unit::TestCase
|
10
10
|
def test_proc_to_ruby
|
11
11
|
util_setup_inline
|
12
12
|
block = proc { puts "something" }
|
data/test/test_unified_ruby.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
$TESTING = true
|
4
4
|
|
5
|
-
require '
|
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 <
|
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.
|
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-
|
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:
|
64
|
+
version: 2.3.0
|
44
65
|
version:
|
45
|
-
description:
|
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.
|
153
|
+
rubygems_version: 1.3.4
|
107
154
|
signing_key:
|
108
|
-
specification_version:
|
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/
|
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