diff options
author | Kevin Newton <[email protected]> | 2025-03-13 09:54:15 -0400 |
---|---|---|
committer | git <[email protected]> | 2025-03-13 14:24:48 +0000 |
commit | f2483c79fe651c3dc5f100348a22f6a34d1d34bd (patch) | |
tree | de90020fd7c5685df928dae750fd03efe129f558 /lib/prism/translation/parser | |
parent | 31cf2684b0bc12cad19356672fcc86c6279b1f22 (diff) |
[ruby/prism] Use Set.new over to_set
https://github.com/ruby/prism/commit/422d5c4c64
Diffstat (limited to 'lib/prism/translation/parser')
-rw-r--r-- | lib/prism/translation/parser/lexer.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb index cc063e88d0..789861593d 100644 --- a/lib/prism/translation/parser/lexer.rb +++ b/lib/prism/translation/parser/lexer.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require "set" require "strscan" module Prism @@ -10,7 +9,7 @@ module Prism # format for the parser gem. class Lexer # These tokens are always skipped - TYPES_ALWAYS_SKIP = %i[IGNORED_NEWLINE __END__ EOF].to_set + TYPES_ALWAYS_SKIP = Set.new(%i[IGNORED_NEWLINE __END__ EOF]) private_constant :TYPES_ALWAYS_SKIP # The direct translating of types between the two lexers. @@ -195,18 +194,18 @@ module Prism # # NOTE: In edge cases like `-> (foo = -> (bar) {}) do end`, please note that `kDO` is still returned # instead of `kDO_LAMBDA`, which is expected: https://github.com/ruby/prism/pull/3046 - LAMBDA_TOKEN_TYPES = [:kDO_LAMBDA, :tLAMBDA, :tLAMBEG].to_set + LAMBDA_TOKEN_TYPES = Set.new([:kDO_LAMBDA, :tLAMBDA, :tLAMBEG]) # The `PARENTHESIS_LEFT` token in Prism is classified as either `tLPAREN` or `tLPAREN2` in the Parser gem. # The following token types are listed as those classified as `tLPAREN`. - LPAREN_CONVERSION_TOKEN_TYPES = [ + LPAREN_CONVERSION_TOKEN_TYPES = Set.new([ :kBREAK, :kCASE, :tDIVIDE, :kFOR, :kIF, :kNEXT, :kRETURN, :kUNTIL, :kWHILE, :tAMPER, :tANDOP, :tBANG, :tCOMMA, :tDOT2, :tDOT3, :tEQL, :tLPAREN, :tLPAREN2, :tLPAREN_ARG, :tLSHFT, :tNL, :tOP_ASGN, :tOROP, :tPIPE, :tSEMI, :tSTRING_DBEG, :tUMINUS, :tUPLUS - ].to_set + ]) # Types of tokens that are allowed to continue a method call with comments in-between. # For these, the parser gem doesn't emit a newline token after the last comment. - COMMENT_CONTINUATION_TYPES = [:COMMENT, :AMPERSAND_DOT, :DOT].to_set + COMMENT_CONTINUATION_TYPES = Set.new([:COMMENT, :AMPERSAND_DOT, :DOT]) private_constant :COMMENT_CONTINUATION_TYPES # Heredocs are complex and require us to keep track of a bit of info to refer to later |