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:
parent
25c00db129
commit
9c3ba20c50
1 changed files with 10 additions and 0 deletions
|
@ -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'
|
||||
|
||||
|
|
Loading…
Reference in a new issue