# ParseTree 1.5.0 Released

**URL:** <https://www.ruby-forum.com/t/parsetree-1-5-0-released/69837>\
**Category:** Ruby\
**Created:** [September 24, 2006, 10:04pm UTC](https://www.ruby-forum.com/t/parsetree-1-5-0-released/69837 "2006-09-24T22:04:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aguynamedryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@aguynamedryan](https://www.ruby-forum.com/u/aguynamedryan)\
**Post date:** [September 24, 2006, 10:04pm UTC](https://www.ruby-forum.com/t/parsetree-1-5-0-released/69837/1 "2006-09-24T22:04:31Z")

</div>

ParseTree version 1.5.0 has been released!

[http://rubyforge.org/projects/parsetree/](http://rubyforge.org/projects/parsetree/)  
[zenspider projects | software projects | by ryan davis](http://www.zenspider.com/ZSS/Products/ParseTree/)

\*\* 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]]]]]

\*\* FEATURES/PROBLEMS:

- Uses RubyInline, so it just drops in.

- Includes SexpProcessor and CompositeSexpProcessor.

- Includes parse\_tree\_show, which lets you quickly snoop code.

- Includes parse\_tree\_abc, which lets you get abc metrics on code.

- Includes parse\_tree\_deps, which shows you basic class level  
dependencies.

- Only works on methods in classes/modules, not arbitrary code.

- Does not work on the core classes, as they are not ruby (yet).

Changes:

- 5 minor enhancements:  
Added parse\_tree\_audit.  
Added reporting of unsupported nodes that have processors.  
YAY! class method support! generated as :“self.blah”  
Add parse\_tree\_for\_string.  
Converted Rakefile+gemspec to Hoe-based Rakefile.

- 6 bug fixes:  
Did some preliminary work on 1.9 compatibility.  
Fixed tests for some changes/clarifications.  
Fixed resbody: should have nil exceptions list when no exception  
rescued.  
Fixed op\_asgn1 and op\_asgn2.  
Fixed incompatibility with new inline changes.  
Fixed VALUE decl in parse\_tree.rb

---

<div class="post-metadata">

**Author:** ![aguynamedryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@aguynamedryan](https://www.ruby-forum.com/u/aguynamedryan)\
**Post date:** [September 25, 2006, 12:36am UTC](https://www.ruby-forum.com/t/parsetree-1-5-0-released/69837/2 "2006-09-25T00:36:48Z")

</div>

On Sun, 24 Sep 2006 22:02:25 +0200, Ryan D.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ParseTree version 1.5.0 has been released!

[snip]

> \*\* FEATURES/PROBLEMS:
> 
> - Uses RubyInline, so it just drops in.

There seems to be a problem with RubyInline’s strip\_comments(). I’m not  
sure what the exact problem is, but it converts

case NODE\_LAMBDA:  
puts(“no worky in 1.9 yet”);  
break;  
#{if\_version :\<, “1.9”, “#endif”}

// Nodes we found but have yet to decypher  
// I think these are all runtime only… not positive but…  
case NODE\_MEMO: // enum.c zip  
case NODE\_CREF:

to

case NODE\_LAMBDA:  
puts(“no worky in 1.9 yet”);  
break;  
#endif case NODE\_MEMO: case NODE\_CREF:

Which obviously won’t compile.

(Tested on ruby 1.8.4 (2005-12-24) [i686-linux] and ruby 1.8.5  
(2006-08-25) [i686-linux], RubyInline-3.6.0, everything installed using  
gems)

[snip]

> Changes:
> 
> - 5 minor enhancements:  
> Added parse\_tree\_audit.  
> Added reporting of unsupported nodes that have processors.  
> YAY! class method support! generated as :“self.blah”  
> Add parse\_tree\_for\_string.

You made a mistake when copying the code from RubyNode:

You always have to set ruby\_eval\_tree\_begin to 0 (in 1.8), otherwise the  
code in BEGIN blocks will be executed the next time eval is called  
(which  
is immediatly in irb):

$ ruby  
require “parse\_tree”  
p ParseTree.new.parse\_tree\_for\_string(“BEGIN { puts ‘evil’ }; puts  
‘hello’”)  
puts “before eval”  
p eval(“‘eval’”)  
^D  
[[:fcall, :puts, [:array, [:str, “hello”]]]]  
before eval  
evil  
“eval”

> Converted Rakefile+gemspec to Hoe-based Rakefile.
> 
> - 6 bug fixes:  
> Did some preliminary work on 1.9 compatibility.  
> Fixed tests for some changes/clarifications.  
> Fixed resbody: should have nil exceptions list when no exception  
> rescued.  
> Fixed op\_asgn1 and op\_asgn2.  
> Fixed incompatibility with new inline changes.  
> Fixed VALUE decl in parse\_tree.rb

There have been changes to NODE\_ALIAS and NODE\_VALIAS in 1.8.5:

$ irb -r parse\_tree

> > ParseTree.new.parse\_tree\_for\_string(“class A; alias a b; end”)  
> > /home/dba/i/ruby-1.8.5/lib/ruby/1.8/irb.rb:298: [BUG] Segmentation fault  
> > ruby 1.8.5 (2006-08-25) [i686-linux]

$ ruby -ve ‘require “parse\_tree”; p  
ParseTree.new.parse\_tree\_for\_string(“class A; alias $a $b; end”)’  
ruby 1.8.4 (2005-12-24) [i686-linux]  
[[:class, :A, [:scope, [:valias, :$b, :$a]]]]

$ ruby -ve ‘require “parse\_tree”; p  
ParseTree.new.parse\_tree\_for\_string(“class A; alias $a $b; end”)’  
ruby 1.8.5 (2006-08-25) [i686-linux]  
[[:class, :A, [:scope, [:valias, :$a, :$b]]]]

Dominik

---

<div class="post-metadata">

**Author:** ![aguynamedryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@aguynamedryan](https://www.ruby-forum.com/u/aguynamedryan)\
**Post date:** [September 25, 2006, 2:26am UTC](https://www.ruby-forum.com/t/parsetree-1-5-0-released/69837/3 "2006-09-25T02:26:54Z")

</div>

On Sep 24, 2006, at 3:36 PM, Dominik B. wrote:

> There seems to be a problem with RubyInline’s strip\_comments(). I’m  
> not sure what the exact problem is, but it converts

Please file a bug.
