From: Aaron Patterson Date: 2007-01-27T10:14:56+09:00 Subject: Re: Working with the parse tree in Ruby? On Sat, Jan 27, 2007 at 09:20:55AM +0900, Martin C. Martin wrote: > Hi, > > In Lisp, it's easy to get the parse tree of an expression, and to > manipulate those parse trees. That means Lisp code tends to use macros, > i.e. lisp functions whose return values are parse trees. These macros > are evaluated at compile time and inserted into the place where the > macro call appears. > > Is there anything equivalent in Ruby? Is there a way in Ruby to get the > parse tree of, say, x + y? Is there a way to execute parse trees? Yes, you can get the parse tree using "ParseTree" http://rubyforge.org/projects/parsetree/ Then convert the parse tree back to ruby with ruby2ruby: http://rubyforge.org/projects/seattlerb/ HTH! -- Aaron Patterson http://tenderlovemaking.com/