1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Use the JRuby parser to validate input (#249)

This commit is contained in:
Darrick Wiebe 2011-10-18 20:12:57 -04:00
parent 25c00db129
commit 9c3ba20c50

View file

@ -530,6 +530,16 @@ class Pry
!!Ripper::SexpBuilder.new(code).parse
end
elsif RUBY_VERSION =~ /1.9/ && RUBY_ENGINE == 'jruby'
# JRuby doesn't have Ripper, so use its native parser for 1.9 mode.
def valid_expression?(code)
JRuby.parse(code)
true
rescue SyntaxError
false
end
else
require 'ruby_parser'