Skip to content

Commit f2483c7

Browse files
kddnewtonmatzbot
authored andcommitted
[ruby/prism] Use Set.new over to_set
ruby/prism@422d5c4c64
1 parent 31cf268 commit f2483c7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/prism/translation/parser/lexer.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "set"
43
require "strscan"
54

65
module Prism
@@ -10,7 +9,7 @@ class Parser
109
# format for the parser gem.
1110
class Lexer
1211
# These tokens are always skipped
13-
TYPES_ALWAYS_SKIP = %i[IGNORED_NEWLINE __END__ EOF].to_set
12+
TYPES_ALWAYS_SKIP = Set.new(%i[IGNORED_NEWLINE __END__ EOF])
1413
private_constant :TYPES_ALWAYS_SKIP
1514

1615
# The direct translating of types between the two lexers.
@@ -195,18 +194,18 @@ class Lexer
195194
#
196195
# NOTE: In edge cases like `-> (foo = -> (bar) {}) do end`, please note that `kDO` is still returned
197196
# instead of `kDO_LAMBDA`, which is expected: https://github.com/ruby/prism/pull/3046
198-
LAMBDA_TOKEN_TYPES = [:kDO_LAMBDA, :tLAMBDA, :tLAMBEG].to_set
197+
LAMBDA_TOKEN_TYPES = Set.new([:kDO_LAMBDA, :tLAMBDA, :tLAMBEG])
199198

200199
# The `PARENTHESIS_LEFT` token in Prism is classified as either `tLPAREN` or `tLPAREN2` in the Parser gem.
201200
# The following token types are listed as those classified as `tLPAREN`.
202-
LPAREN_CONVERSION_TOKEN_TYPES = [
201+
LPAREN_CONVERSION_TOKEN_TYPES = Set.new([
203202
:kBREAK, :kCASE, :tDIVIDE, :kFOR, :kIF, :kNEXT, :kRETURN, :kUNTIL, :kWHILE, :tAMPER, :tANDOP, :tBANG, :tCOMMA, :tDOT2, :tDOT3,
204203
:tEQL, :tLPAREN, :tLPAREN2, :tLPAREN_ARG, :tLSHFT, :tNL, :tOP_ASGN, :tOROP, :tPIPE, :tSEMI, :tSTRING_DBEG, :tUMINUS, :tUPLUS
205-
].to_set
204+
])
206205

207206
# Types of tokens that are allowed to continue a method call with comments in-between.
208207
# For these, the parser gem doesn't emit a newline token after the last comment.
209-
COMMENT_CONTINUATION_TYPES = [:COMMENT, :AMPERSAND_DOT, :DOT].to_set
208+
COMMENT_CONTINUATION_TYPES = Set.new([:COMMENT, :AMPERSAND_DOT, :DOT])
210209
private_constant :COMMENT_CONTINUATION_TYPES
211210

212211
# Heredocs are complex and require us to keep track of a bit of info to refer to later

0 commit comments

Comments
 (0)