[前][次][番号順一覧][スレッド一覧]

ruby-changes:64240

From: Nobuhiro <ko1@a...>
Date: Thu, 17 Dec 2020 20:24:48 +0900 (JST)
Subject: [ruby-changes:64240] cbf6a7f906 (master): [ruby/irb] workaround for lack of tokens from `Ripper.lex`

https://git.ruby-lang.org/ruby.git/commit/?id=cbf6a7f906

From cbf6a7f906d17968c8f54f4efb1899e9b204ccfe Mon Sep 17 00:00:00 2001
From: Nobuhiro IMAI <nov@y...>
Date: Sat, 21 Nov 2020 08:40:31 +0900
Subject: [ruby/irb] workaround for lack of tokens from `Ripper.lex`

* Fixes #38

https://github.com/ruby/irb/commit/905fb8e52e

diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 51efc17..0302282 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -88,9 +88,12 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L88
 
   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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]