From: Thomas Chust Date: 2009-08-04T22:50:50+09:00 Subject: Re: Kind of ParsTree for 1.9.1 2009/8/4 Macario Ortega : > [...] > Hi, I've been missing ParseTree very badly in 1.9.1. So in my naivité I > decided to try to convert YARV iseq's to Sexp's similar of those > produced by ParseTree. > [...] > Is someone aware of a similar effort? > [...] Hello, the Ruby 1.9.1p243 that I installed from source came with a library called 'ripper' that can produce S-expression parse trees from Ruby code, like this: $ cat foo.rb require 'ripper' require 'pp' pp Ripper.sexp %{ def foo :bar end } $ ruby foo.rb [:program, [[:def, [:@ident, "foo", [2, 6]], [:params, nil, nil, nil, nil, nil], [:body_stmt, [[:symbol_literal, [:symbol, [:@ident, "bar", [3, 5]]]]], nil, nil, nil]]]] I played around with that a little, but didn't try to code anything serious. Also, since I'm new to Ruby and haven't used ParseTree before, I don't know how compatible the abstract syntax tree representations are. cu, Thomas -- When C++ is your hammer, every problem looks like your thumb.