Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

ParseTree 2.0.0 Released

By Peter Cooper / August 6, 2007


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
return 0


[:args, :arg1],
[:call, [:lvar, :arg1], :==, [:array, [:lit, 0]]],
[:return, [:lit, 1]],
[:return, [:lit, 0]]]]]

There are many significant enhancements beyond the 1.x.x family, so check it out.


  1. Mourner says:

    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.

  2. carlity says:

    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?

  3. Ben says:

    Could this be the basis for a rubytidy? (a'la perltidy - - source re-formatter).

  4. Martijn says:

    I have no idea how or why this is used. Can someone who does please enlighten us?

  5. shadytrees says:

    RubyTidy's already taken, but the project seems to be standstill without any tidy code in SVN.

    Polish would be a nice name for a Ruby tidy-er though.

Other Posts to Enjoy

Twitter Mentions