Skip to content

Instantly share code, notes, and snippets.

@webmat
Created November 20, 2008 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmat/27156 to your computer and use it in GitHub Desktop.
Save webmat/27156 to your computer and use it in GitHub Desktop.
#console
sudo gem install ruby_parser
#irb
require 'rubygems' ; require 'ruby_parser' ; require 'pp'
pp RubyParser.new.parse "class C
def meth(arg)
arg * 2
end
end"
#=>
s(:class,
:C,
nil,
s(:scope,
s(:defn,
:meth,
s(:args, :arg),
s(:scope,
s(:block,
s(:return, s(:call, s(:lvar, :arg), :*, s(:arglist, s(:lit, 2)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment