summaryrefslogtreecommitdiff
path: root/ext/ripper/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-25 02:28:49 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-25 02:28:49 +0000
commit7c885222ca1d038006819afda93758cf1425ec66 (patch)
treecae44c01cfc1cafc78af5b302e8dd8bdf78ab802 /ext/ripper/lib
parentb5909efd1376231e8a820226506c999446730781 (diff)
* ext/ripper/lib/ripper/sexp.rb: fix rdoc arround sexp.
patched by Sho Hashimoto. fixes #4599 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/ripper/lib')
-rw-r--r--ext/ripper/lib/ripper/sexp.rb25
1 files changed, 20 insertions, 5 deletions
diff --git a/ext/ripper/lib/ripper/sexp.rb b/ext/ripper/lib/ripper/sexp.rb
index f2260fe..37040e4 100644
--- a/ext/ripper/lib/ripper/sexp.rb
+++ b/ext/ripper/lib/ripper/sexp.rb
@@ -14,13 +14,32 @@ class Ripper
# [EXPERIMENTAL]
# Parses +src+ and create S-exp tree.
+ # Returns more readable tree rather than Ripper.sexp_raw.
# This method is for mainly developper use.
#
# require 'ripper'
- # require 'pp
+ # require 'pp'
#
# pp Ripper.sexp("def m(a) nil end")
# #=> [:program,
+ # [[:def,
+ # [:@ident, "m", [1, 4]],
+ # [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil]],
+ # [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]]
+ #
+ def Ripper.sexp(src, filename = '-', lineno = 1)
+ SexpBuilderPP.new(src, filename, lineno).parse
+ end
+
+ # [EXPERIMENTAL]
+ # Parses +src+ and create S-exp tree.
+ # This method is for mainly developper use.
+ #
+ # require 'ripper'
+ # require 'pp'
+ #
+ # pp Ripper.sexp_raw("def m(a) nil end")
+ # #=> [:program,
# [:stmts_add,
# [:stmts_new],
# [:def,
@@ -32,10 +51,6 @@ class Ripper
# nil,
# nil]]]]
#
- def Ripper.sexp(src, filename = '-', lineno = 1)
- SexpBuilderPP.new(src, filename, lineno).parse
- end
-
def Ripper.sexp_raw(src, filename = '-', lineno = 1)
SexpBuilder.new(src, filename, lineno).parse
end