aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNobuhiro IMAI <nov@yo.rim.or.jp>2020-11-21 08:40:31 +0900
committeraycabta <aycabta@gmail.com>2020-12-17 20:22:29 +0900
commitcbf6a7f906d17968c8f54f4efb1899e9b204ccfe (patch)
tree5529745abb67f6ee9ed61b1becb4cf4cea852519 /lib
parent422e2c7274d9dbf1ff93dccc0c3c388f4775e636 (diff)
downloadruby-cbf6a7f906d17968c8f54f4efb1899e9b204ccfe.tar.gz
[ruby/irb] workaround for lack of tokens from `Ripper.lex`
* Fixes #38 https://github.com/ruby/irb/commit/905fb8e52e
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/ruby-lex.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 51efc17433..03022822bb 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -88,9 +88,12 @@ class RubyLex
def ripper_lex_without_warning(code)
verbose, $VERBOSE = $VERBOSE, nil
- tokens = nil
+ tokens = []
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
$VERBOSE = verbose
tokens