Forum: Ruby parse tree for 1.9

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2008-10-10 07:32
Anybody know if there is anything like parse_tree for 1.9?
Thanks!
-=R
669b7046f02e5dfc4bda4421f1069731?d=identicon&s=25 Alex Fenton (Guest)
on 2008-10-10 10:06
(Received via mailing list)
Roger Pack wrote:
> Anybody know if there is anything like parse_tree for 1.9?
> Thanks!


Perhaps RubyVM::InstructionSequence.compile or
RubyVM::InstructionSequence::compile_file will do something similar to
what you want. These methods are standard in 1.9

alex
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2008-10-10 10:32
(Received via mailing list)
On Oct 9, 2008, at 22:30 PM, Roger Pack wrote:
> Anybody know if there is anything like parse_tree for 1.9?

require 'ripper'
Ripper.sexp '1 + 1' #=> [:program, [[:binary, [:@int, "1", [1, 0]], :
+, [:@int, "1", [1, 4]]]]]
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2008-10-10 10:33
(Received via mailing list)
On Oct 9, 2008, at 22:30 , Roger Pack wrote:

> Anybody know if there is anything like parse_tree for 1.9?

ruby_parser (new and massively improved release coming soon)... don't
let the 1.0.0 release bias your opinion too much.

The only thing it doesn't do is ASTs of runtime objects (procs,
methods, classes/modules). It is 100% compatible with ParseTree's
output tho (that also has a big release coming and there is some
incompatibilities, tho minor).
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2008-10-10 10:35
(Received via mailing list)
On Oct 10, 2008, at 01:02 , Alex Fenton wrote:

> Roger Pack wrote:
>> Anybody know if there is anything like parse_tree for 1.9?
>> Thanks!
>
>
> Perhaps RubyVM::InstructionSequence.compile or
> RubyVM::InstructionSequence::compile_file will do something similar
> to what you want. These methods are standard in 1.9

unfortunately, no... that's not even close. :(

I've asked multiple times if we could get bytecode for procs and short
of writing more C extensions to hack it out myself, I doubt it'll ever
show. Even still, we'd have to write a bytecode decompiler to
something that was remotely readable/usable. That's a lot of work.
This topic is locked and can not be replied to.