summaryrefslogtreecommitdiff
path: root/lib/irb/ruby-lex.rb
diff options
context:
space:
mode:
authorMau Magnaguagno <maumagnaguagno@gmail.com>2022-12-27 14:05:28 -0300
committergit <svn-admin@ruby-lang.org>2022-12-27 17:05:32 +0000
commitec7e082906d5c32c5e895137fd0d562fa237ca12 (patch)
tree23694ec6c2f56ed3d4d9cb9d7686121c59af2b93 /lib/irb/ruby-lex.rb
parent140c93e2dcdccc640a3be3ad6b5f7a7696587dbc (diff)
[ruby/irb] Refactor RubyLex#process_literal_type
(https://github.com/ruby/irb/pull/350) Simplify part of regex ``[_a-zA-Z0-9]`` with equivalent shorthand ``\w``. Replace case-when with match ``$1`` or default value ``?"``, making intention more clear.
Diffstat (limited to 'lib/irb/ruby-lex.rb')
-rw-r--r--lib/irb/ruby-lex.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 030cf79ee1..04d9bceb07 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -782,13 +782,8 @@ class RubyLex
when :on_qsymbols_beg then ?]
when :on_symbols_beg then ?]
when :on_heredoc_beg
- start_token&.tok =~ /<<[-~]?(['"`])[_a-zA-Z0-9]+\1/
- case $1
- when ?" then ?"
- when ?' then ?'
- when ?` then ?`
- else ?"
- end
+ start_token&.tok =~ /<<[-~]?(['"`])\w+\1/
+ $1 || ?"
else
nil
end