sexp(src, filename = '-', lineno = 1) public
EXPERIMENTAL

Parses src and create S-exp tree. This method is for mainly developper use.

require 'ripper'
require 'pp

pp Ripper.sexp("def m(a) nil end")
  #=> [:program,
       [:stmts_add,
        [:stmts_new],
        [:def,
         [:@ident, "m", [1, 4]],
         [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil]],
         [:bodystmt,
          [:stmts_add, [:stmts_new], [:var_ref, [:@kw, "nil", [1, 9]]]],
          nil,
          nil,
          nil]]]]
Show source
Register or log in to add new notes.