Sha256: 8cd3ddcd9b07d84be0ca1b845c45b1340cb1a24f12739c9dcb49feb249974f8c

Contents?: true

Size: 1.67 KB

Versions: 19

Compression:

Stored size: 1.67 KB

Contents

module Mutant
  module AST
    # Groups of node types
    module Types
      symbolset = ->(strings) { strings.map(&:to_sym).to_set.freeze }

      ASSIGNABLE_VARIABLES = symbolset.(%w[ivasgn lvasgn cvasgn gvasgn])

      INDEX_ASSIGN_OPERATOR = :[]=

      # Set of nodes that cannot be on the LHS of an assignment
      NOT_ASSIGNABLE         = symbolset.(%w[int float str dstr class module self nil])

      # Set of op-assign types
      OP_ASSIGN              = symbolset.(%w[or_asgn and_asgn op_asgn])
      # Set of node types that are not valid when emitted standalone
      NOT_STANDALONE         = symbolset.(%w[splat restarg block_pass])
      INDEX_OPERATORS        = symbolset.(%w[[] []=])
      UNARY_METHOD_OPERATORS = symbolset.(%w[~@ +@ -@ !])

      # Operators ruby implements as methods
      METHOD_OPERATORS = symbolset.(%w[
        <=> === []= [] <= >= == !~ != =~ <<
        >> ** * % / | ^ & < > + - ~@ +@ -@ !
      ])

      BINARY_METHOD_OPERATORS = symbolset.(
        METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)
      )

      OPERATOR_METHODS = symbolset.(
        METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
      )

      # Nodes that are NOT handled by mutant.
      #
      # not - 1.8 only, mutant does not support 1.8
      #
      BLACKLIST = symbolset.(%w[not])

      # Nodes that are NOT generated by parser but used by mutant / unparser.
      EXTRA = symbolset.(%w[empty])

      # Nodes that are currently missing from parser META
      MISSING = symbolset.(%w[rational])

      # All node types mutant handles
      ALL = symbolset.((Parser::Meta::NODE_TYPES + EXTRA + MISSING) - BLACKLIST)
    end # Types
  end # AST
end # Mutant

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mutant-0.8.9 lib/mutant/ast/types.rb
mutant-0.8.8 lib/mutant/ast/types.rb
mutant-0.8.7 lib/mutant/ast/types.rb
mutant-0.8.6 lib/mutant/ast/types.rb
mutant-0.8.5 lib/mutant/ast/types.rb
mutant-0.8.4 lib/mutant/ast/types.rb
mutant-0.8.3 lib/mutant/ast/types.rb
mutant-0.8.2 lib/mutant/ast/types.rb
mutant-0.8.1 lib/mutant/ast/types.rb
mutant-0.8.0 lib/mutant/ast/types.rb
mutant-0.7.9 lib/mutant/ast/types.rb
mutant-0.7.8 lib/mutant/ast/types.rb
mutant-0.7.7 lib/mutant/ast/types.rb
mutant-0.7.6 lib/mutant/ast/types.rb
mutant-0.7.5 lib/mutant/ast/types.rb
mutant-0.7.4 lib/mutant/ast/types.rb
mutant-0.7.3 lib/mutant/ast/types.rb
mutant-0.7.2 lib/mutant/ast/types.rb
mutant-0.7.1 lib/mutant/ast/types.rb