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

[ruby/irb] workaround for lack of tokens from Ripper.lex

* Fixes #38

905fb8e52e
This commit is contained in:
Nobuhiro IMAI 2020-11-21 08:40:31 +09:00 committed by aycabta
parent 422e2c7274
commit cbf6a7f906

View file

@ -88,9 +88,12 @@ class RubyLex
def ripper_lex_without_warning(code) def ripper_lex_without_warning(code)
verbose, $VERBOSE = $VERBOSE, nil verbose, $VERBOSE = $VERBOSE, nil
tokens = nil tokens = []
self.class.compile_with_errors_suppressed(code) do |inner_code, line_no| self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
tokens = Ripper.lex(inner_code, '-', line_no) lexer = Ripper::Lexer.new(inner_code, '-', line_no)
until (ts = lexer.lex).empty?
tokens.concat(ts)
end
end end
$VERBOSE = verbose $VERBOSE = verbose
tokens tokens