[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.
This commit is contained in:
Mau Magnaguagno 2022-12-27 14:05:28 -03:00 committed by git
parent 140c93e2dc
commit ec7e082906

View File

@ -782,13 +782,8 @@ class RubyLex
when :on_qsymbols_beg then ?] when :on_qsymbols_beg then ?]
when :on_symbols_beg then ?] when :on_symbols_beg then ?]
when :on_heredoc_beg when :on_heredoc_beg
start_token&.tok =~ /<<[-~]?(['"`])[_a-zA-Z0-9]+\1/ start_token&.tok =~ /<<[-~]?(['"`])\w+\1/
case $1 $1 || ?"
when ?" then ?"
when ?' then ?'
when ?` then ?`
else ?"
end
else else
nil nil
end end