# ParseTree 2.2.0 Released

**URL:** <https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027>\
**Category:** Ruby\
**Created:** [June 10, 2008, 6:18am UTC](https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027 "2008-06-10T06:18:52Z")\
**Posts on this page:** 6\
**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:** [June 10, 2008, 6:18am UTC](https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027/1 "2008-06-10T06:18:52Z")

</div>

ParseTree version 2.2.0 has been released!

- [http://rubyforge.org/projects/parsetree/](http://rubyforge.org/projects/parsetree/)
- [http://www.zenspider.com/ZSS/Products/ParseTree/](http://www.zenspider.com/ZSS/Products/ParseTree/)
- [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

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

Changes:

### 2.2.0 / 2008-06-09

- 18 minor enhancements:

- 3 bug fixes:

- [http://rubyforge.org/projects/parsetree/](http://rubyforge.org/projects/parsetree/)

- [http://www.zenspider.com/ZSS/Products/ParseTree/](http://www.zenspider.com/ZSS/Products/ParseTree/)

- [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<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:** [June 10, 2008, 11:32am UTC](https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027/2 "2008-06-10T11:32:58Z")

</div>

Ryan D. wrote:

> […]
> 
> ### 2.2.0 / 2008-06-09
> 
> - 18 minor enhancements:

I’m curious. Does that mean, ParseTree now works with Ruby 1.9? That  
would be great!

Regards,

Michael

---

<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:** [June 10, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027/3 "2008-06-10T14:34:45Z")

</div>

Dear Ryan,

> ParseTree version 2.2.0 has been released!  
> 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.

can you recommend an analogon to ParseTree for classes and methods  
written in C/C++,  
which produces output that’s compatible/easily adaptable to ParseTree’s  
output for Ruby, i.e., that would  
facilitate translations of code

Ruby -\> S-Expressions -\> C/C++ and in the other direction ?

Thank you very much!

Best regards,

Axel

---

<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:** [June 11, 2008, 2:21am UTC](https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027/4 "2008-06-11T02:21:29Z")

</div>

On Jun 10, 2008, at 02:32 , Michael N. wrote:

> would be great!  
> Unfortunately, no.

My 1.9 fixes were for SexpProcessor only. The intent is to get to the  
point where 1.9 and other non-ASTable implementations can  
automatically fall back to ruby\_parser.

1.9 dropped support for storing AST information. ruby\_parser can take  
over for some of that, but the biggie is procs… People who design  
DSLs on procs using ruby2ruby to do manipulation are going to be  
sorely disappointed in ruby 1.9. Unfortunately I don’t have a solution  
at this time. There has been some talk about a bytecode decompiler for  
procs, but I don’t even know if it is feasible at this point.

---

<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:** [June 11, 2008, 2:25am UTC](https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027/5 "2008-06-11T02:25:34Z")

</div>

On Jun 10, 2008, at 05:34 , Axel E. wrote:

> adaptable to ParseTree’s output for Ruby, i.e., that would  
> facilitate translations of code

I’m confused… above it seems you’re asking for something like  
ParseTree for C/++. Below it seems you’re asking for a sexp to C  
translator. Or… you want it bidirectional???

> Ruby -\> S-Expressions -\> C/C++ and in the other direction ?

Any C/++ parser could be adapted to generate ruby objects that look  
like sexps. But conceptually there is a lot of disparity between C, C+  
+, and ruby. I doubt you’ll ever manage a clean bidirectional mapping  
between the two except for the most hamstrung subset between the three.

Curious tho: why?

---

<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:** [June 14, 2008, 12:44pm UTC](https://www.ruby-forum.com/t/parsetree-2-2-0-released/140027/6 "2008-06-14T12:44:25Z")

</div>

-------- Original-Nachricht --------

> Datum: Wed, 11 Jun 2008 09:24:32 +0900  
> Von: Ryan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: removed\_email\_address@domain.invalid  
> Betreff: Re: [ANN] ParseTree 2.2.0 Released

> > can you recommend an analogon to ParseTree for classes and methods  
> > written in C/C++, which produces output that’s compatible/easily  
> > adaptable to ParseTree’s output for Ruby, i.e., that would  
> > facilitate translations of code

Dear Ryan,

> I’m confused… above it seems you’re asking for something like  
> ParseTree for C/++. Below it seems you’re asking for a sexp to C  
> translator. Or… you want it bidirectional???
> 
> Curious tho: why?

well, your project somehow revives a dream I have about somehow easier  
integration of code in different languages, so indeed, I’d take  
bidirectional  
if I’d get it 🙂

> Any C/++ parser could be adapted to generate ruby objects that look  
> like sexps. But conceptually there is a lot of disparity between C, C+  
> +, and ruby. I doubt you’ll ever manage a clean bidirectional mapping  
> between the two except for the most hamstrung subset between the three.

It’s just a dream now, but I was wondering for some time whether it  
shouldn’t  
be possible to make a mapping of concepts between different programming  
languages in the following way.

—Two necessary prerequistes –

1. If you have a text (about any subject), you can automatically  
summarize it (i.e.,  
keep only the, say, 10 percent most interesting sentences in it). and  
categorize  
different sentences in it using a technique called Latent Semantic  
Analysis.  
There is a Ruby implementation of this technique in the classifier gem:

[http://classifier.rubyforge.org/](http://classifier.rubyforge.org/)

and the usage examples there.  
Latent Semantic Analysis transforms a text into a “matrix” by counting  
the number  
of occurrences of words in a sentence, and similar sentences are  
identified as  
“vectors” which are mapped “closely together” in a set called the  
“eigenspace” of that  
matrix. The terms in quotation marks are precisely defined in linear  
algebra.

1. Suppose you have two somewhat encylopaedic books explaining how to  
code in  
language X and language Y, from the ground up, so that you can search  
their entire  
text from your computer (that should be possible from a O’Reilly Safari  
subscription).

The idea I have is about this:  
Now, to transform a piece of code T in language X into one in language  
Y, I think it would be  
feasible to use the S-expressions of T, to identify those pieces of  
code in the book  
about language X that have their S-expressions resemble most to those of  
T ( in the  
linear algebra distance sense), and then try to find the parts of  
explanatory text and code in the book about language Y, that resemble  
most to that text in the book about language X.

Best regards,

Axel
