summaryrefslogtreecommitdiff
path: root/ext/ripper/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-26 03:24:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-26 03:24:18 +0000
commitd1ec43ae7ab2a4e529ee8eed21c2894b565a6862 (patch)
tree2878cbb473453a90bb617788866cc4961bd22948 /ext/ripper/lib
parent3bf0628a70ea72b55713458d40271dd3e5537d19 (diff)
parse.y: Ripper.sexp returns error
* ext/ripper/lib/ripper/sexp.rb (Ripper.sexp, Ripper.sexp_raw): return nil on error. [ruby-dev:48678] [Bug #10405] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/ripper/lib')
-rw-r--r--ext/ripper/lib/ripper/sexp.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/ripper/lib/ripper/sexp.rb b/ext/ripper/lib/ripper/sexp.rb
index 66bd691..150c6f0 100644
--- a/ext/ripper/lib/ripper/sexp.rb
+++ b/ext/ripper/lib/ripper/sexp.rb
@@ -28,7 +28,9 @@ class Ripper
# [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]]
#
def Ripper.sexp(src, filename = '-', lineno = 1)
- SexpBuilderPP.new(src, filename, lineno).parse
+ builder = SexpBuilderPP.new(src, filename, lineno)
+ sexp = builder.parse
+ sexp unless builder.error?
end
# [EXPERIMENTAL]
@@ -52,7 +54,9 @@ class Ripper
# nil]]]]
#
def Ripper.sexp_raw(src, filename = '-', lineno = 1)
- SexpBuilder.new(src, filename, lineno).parse
+ builder = SexpBuilder.new(src, filename, lineno)
+ sexp = builder.parse
+ sexp unless builder.error?
end
class SexpBuilderPP < ::Ripper #:nodoc: