diff options
author | Nobuhiro IMAI <[email protected]> | 2020-11-21 08:40:31 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2020-12-17 20:22:29 +0900 |
commit | cbf6a7f906d17968c8f54f4efb1899e9b204ccfe (patch) | |
tree | 5529745abb67f6ee9ed61b1becb4cf4cea852519 /lib | |
parent | 422e2c7274d9dbf1ff93dccc0c3c388f4775e636 (diff) |
[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.rb | 7 |
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 |