ParseTree 1.3.5 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Makefile +3 -3
- data/bin/parse_tree_show +2 -1
- data/lib/parse_tree.rb +11 -3
- data/lib/sexp_processor.rb +11 -8
- data/test/test_parse_tree.rb +15 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
*** 1.3.6 / 2005-05-19
|
2
|
+
|
3
|
+
+ 2 minor enhancements:
|
4
|
+
+ Improved debugging capability when $DEBUG.
|
5
|
+
+ Allowed for selective debugging output by node type.
|
6
|
+
+ 3 bug fixes:
|
7
|
+
+ Minor fixes to Makefile and parse_tree_show.
|
8
|
+
+ Improved error messages in parse_tree when newlines are included.
|
9
|
+
+ Improved method coverage for parse_tree.
|
10
|
+
|
1
11
|
*** 1.3.5 / 2005-04-19
|
2
12
|
|
3
13
|
+ 2 minor enhancement
|
data/Makefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
RUBY?=ruby
|
2
2
|
RUBY_DEBUG?=
|
3
|
-
RUBY_FLAGS?=-w -Ilib
|
3
|
+
RUBY_FLAGS?=-w -Ilib:bin:../../RubyInline/dev
|
4
4
|
RUBY_LIB?=$(shell $(RUBY) -rrbconfig -e 'include Config; print CONFIG["sitelibdir"]')
|
5
5
|
PREFIX?=/usr/local
|
6
6
|
|
7
7
|
all test: FORCE
|
8
|
-
GEM_SKIP=ParseTree $(RUBY) $(RUBY_DEBUG) $(RUBY_FLAGS) test/test_all.rb
|
8
|
+
GEM_SKIP=RubyInline:ParseTree $(RUBY) $(RUBY_DEBUG) $(RUBY_FLAGS) test/test_all.rb
|
9
9
|
|
10
10
|
# we only install test_sexp_processor.rb to help make ruby_to_c's
|
11
11
|
# subclass tests work.
|
@@ -33,7 +33,7 @@ clean:
|
|
33
33
|
-rm -fr diff diff.txt *.gem doc $$HOME/.ruby_inline
|
34
34
|
|
35
35
|
demo:
|
36
|
-
echo 1+1 | GEM_SKIP=ParseTree $(RUBY) $(RUBY_FLAGS) ./bin/parse_tree_show -f
|
36
|
+
echo 1+1 | GEM_SKIP=RubyInline:ParseTree $(RUBY) $(RUBY_FLAGS) ./bin/parse_tree_show -f
|
37
37
|
|
38
38
|
gem:
|
39
39
|
gem ParseTree.gemspec
|
data/bin/parse_tree_show
CHANGED
data/lib/parse_tree.rb
CHANGED
@@ -28,13 +28,16 @@ end
|
|
28
28
|
|
29
29
|
class ParseTree
|
30
30
|
|
31
|
-
VERSION = '1.3.
|
31
|
+
VERSION = '1.3.6'
|
32
32
|
|
33
33
|
##
|
34
34
|
# Initializes a ParseTree instance. Includes newline nodes if
|
35
35
|
# +include_newlines+ which defaults to +$DEBUG+.
|
36
36
|
|
37
37
|
def initialize(include_newlines=$DEBUG)
|
38
|
+
if include_newlines then
|
39
|
+
warn "WARNING: include_newlines=true from #{caller[0..9].join(', ')}"
|
40
|
+
end
|
38
41
|
@include_newlines = include_newlines
|
39
42
|
end
|
40
43
|
|
@@ -56,7 +59,7 @@ class ParseTree
|
|
56
59
|
klasses.each do |klass|
|
57
60
|
# TODO: remove this on v 1.1
|
58
61
|
raise "You should call parse_tree_for_method(#{klasses.first}, #{klass}) instead of parse_tree" if Symbol === klass or String === klass
|
59
|
-
klassname = klass.name
|
62
|
+
klassname = klass.name rescue '' # HACK klass.name should never be nil
|
60
63
|
# Tempfile's DelegateClass(File) seems to
|
61
64
|
# cause this
|
62
65
|
klassname = "UnnamedClass_#{klass.object_id}" if klassname.empty?
|
@@ -70,7 +73,12 @@ class ParseTree
|
|
70
73
|
[:module, klassname]
|
71
74
|
end
|
72
75
|
|
73
|
-
|
76
|
+
method_names = []
|
77
|
+
method_names += klass.instance_methods false
|
78
|
+
method_names += klass.private_instance_methods false
|
79
|
+
# protected methods are included in instance_methods, go figure!
|
80
|
+
|
81
|
+
method_names.sort.each do |m|
|
74
82
|
$stderr.puts "parse_tree_for_method(#{klass}, #{m}):" if $DEBUG
|
75
83
|
code << parse_tree_for_method(klass, m.to_sym)
|
76
84
|
end
|
data/lib/sexp_processor.rb
CHANGED
@@ -335,16 +335,18 @@ class SexpProcessor
|
|
335
335
|
def process(exp)
|
336
336
|
return nil if exp.nil?
|
337
337
|
|
338
|
-
exp_orig = exp.deep_clone if $DEBUG or @exceptions.has_key?(exp.first)
|
339
338
|
result = self.expected.new
|
340
339
|
|
341
340
|
type = exp.first
|
342
341
|
|
343
|
-
if @debug.
|
342
|
+
if @debug.has_key? type then
|
344
343
|
str = exp.inspect
|
345
344
|
puts "// DEBUG: #{str}" if str =~ @debug[type]
|
346
345
|
end
|
347
346
|
|
347
|
+
exp_orig = exp.deep_clone if $DEBUG or
|
348
|
+
@debug.has_key? type or @exceptions.has_key?(type)
|
349
|
+
|
348
350
|
if Sexp === exp then
|
349
351
|
if @sexp_accessors.include? type then
|
350
352
|
exp.accessors = @sexp_accessors[type]
|
@@ -441,14 +443,15 @@ class SexpProcessor
|
|
441
443
|
end
|
442
444
|
|
443
445
|
def error_handler(type, exp=nil) # :nodoc:
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
446
|
+
begin
|
447
|
+
return yield
|
448
|
+
rescue Exception => err
|
449
|
+
if @exceptions.has_key? type then
|
448
450
|
return @exceptions[type].call(self, exp, err)
|
451
|
+
else
|
452
|
+
puts "#{err.class} Exception thrown while processing #{type} for sexp #{exp.inspect} #{caller.inspect}" if $DEBUG
|
453
|
+
raise
|
449
454
|
end
|
450
|
-
else
|
451
|
-
return yield
|
452
455
|
end
|
453
456
|
end
|
454
457
|
private :error_handler
|
data/test/test_parse_tree.rb
CHANGED
@@ -4,8 +4,23 @@ require 'test/unit'
|
|
4
4
|
require 'parse_tree'
|
5
5
|
require 'test/something'
|
6
6
|
|
7
|
+
class SomethingWithInitialize
|
8
|
+
def initialize; end # this method is private
|
9
|
+
protected
|
10
|
+
def protected_meth; end
|
11
|
+
end
|
12
|
+
|
7
13
|
class TestParseTree < Test::Unit::TestCase
|
8
14
|
|
15
|
+
def test_class_initialize
|
16
|
+
expected = [[:class, :SomethingWithInitialize, :Object,
|
17
|
+
[:defn, :initialize, [:scope, [:block, [:args], [:nil]]]],
|
18
|
+
[:defn, :protected_meth, [:scope, [:block, [:args], [:nil]]]],
|
19
|
+
]]
|
20
|
+
tree = @thing.parse_tree SomethingWithInitialize
|
21
|
+
assert_equal expected, tree
|
22
|
+
end
|
23
|
+
|
9
24
|
# TODO: need a test of interpolated strings
|
10
25
|
|
11
26
|
@@missing = [nil]
|
metadata
CHANGED