# Bug?: Ruby2Ruby and ParseTree on IronRuby

**URL:** <https://www.ruby-forum.com/t/bug-ruby2ruby-and-parsetree-on-ironruby/181767>\
**Category:** IronRuby\
**Created:** [January 18, 2010, 1:12am UTC](https://www.ruby-forum.com/t/bug-ruby2ruby-and-parsetree-on-ironruby/181767 "2010-01-18T01:12:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 18, 2010, 1:12am UTC](https://www.ruby-forum.com/t/bug-ruby2ruby-and-parsetree-on-ironruby/181767/1 "2010-01-18T01:12:37Z")

</div>

Hi guys,

For a project I want to be able to get access to the block definition  
as a string.

After some help I came up with this: [Parse\_Ruby.rb · GitHub](http://gist.github.com/279656)

This solves the problem. When I run the same code on top of IronRuby,  
I get the following error message:

/Users/Ben/Library/ironruby-0.9.3/lib/ironruby/gems/1.8/gems/ParseTree-3.0.4/lib/parse\_tree\_extensions.rb:52:in  
`to_sexp': undefined method `parse\_tree\_for\_proc’ for  
#\<ParseTree:0x0000726 @include\_newlines=false\> (NoMethodError)  
from  
/Users/Ben/Library/ironruby-0.9.3/lib/ironruby/gems/1.8/gems/ParseTree-3.0.4/lib/parse\_tree\_extensions.rb:57:in  
`to_ruby' from mock.rb:31:in `block\_as\_string’  
from mock.rb:34

Any ideas on this? It’s using Ruby2Ruby and ParseTree. Is it because  
it’s based around C extensions? Anyone know how to do it on the CLR?

Thanks

Ben

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 18, 2010, 3:33am UTC](https://www.ruby-forum.com/t/bug-ruby2ruby-and-parsetree-on-ironruby/181767/2 "2010-01-18T03:33:08Z")

</div>

> Any ideas on this? It’s using Ruby2Ruby and ParseTree. Is it because it’s  
> based around C extensions? Anyone know how to do it on the CLR?

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

ParseTree hooks into MRI’s internals and exposes the parse tree for a  
given chunk of Ruby code. For this to work on IronRuby you’d have to  
rewrite the C-extension-portion of this library to look at the DLR trees  
(may require changes to ironruby as well to expose the tree, but I’m not  
sure).

Ruby2Ruby is just a Ruby parser written in Ruby, but depends on racc,  
which uses a C extension, though it seems like you can run racc without  
it.

~Jimmy

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 18, 2010, 4:00am UTC](https://www.ruby-forum.com/t/bug-ruby2ruby-and-parsetree-on-ironruby/181767/3 "2010-01-18T04:00:39Z")

</div>

Considering we have access to the AST… I would think that… in theory  
at  
least, it would be EASIER to implement than CRuby…

But yeah, what Jimmy said 🙂

On Sun, Jan 17, 2010 at 9:32 PM, Jimmy S. \<
