ParseTree 2.0.0 Released
Ryan Davis has released the second major version of ParseTree, a much loved Ruby library that extracts parse trees for Ruby classes and methods and returns them in an s-expression type format using standard Ruby data types. It relies on Ryan's other well known library, RubyInline. In his announcement, Ryan gives a demonstration:
As an example:
def conditional1(arg1)
if arg1 == 0 then
return 1
end
return 0
endbecomes:
[:defn,
:conditional1,
[:scope,
[:block,
[:args, :arg1],
[:if,
[:call, [:lvar, :arg1], :==, [:array, [:lit, 0]]],
[:return, [:lit, 1]],
nil],
[:return, [:lit, 0]]]]]
There are many significant enhancements beyond the 1.x.x family, so check it out.
August 6, 2007 at 12:24 pm
I would love to understand someday where, how and why it is used - at the moment this is one of the most bizarre ruby libraries for me.
August 6, 2007 at 9:57 pm
I too would like to know where people are using ruby code converted to s expressions. Maybe for converting ruby to other languages? Anyone have small and practical examples?
August 6, 2007 at 10:13 pm
Could this be the basis for a rubytidy? (a'la perltidy - http://perltidy.sourceforge.net/ - source re-formatter).
August 7, 2007 at 9:42 am
I have no idea how or why this is used. Can someone who does please enlighten us?
August 7, 2007 at 9:28 pm
RubyTidy's already taken, but the project seems to be standstill without any tidy code in SVN.
https://rubyforge.org/projects/rubytidy/
Polish would be a nice name for a Ruby tidy-er though.