Sha256: 69ca94ec159641acee9b05b1edf5a4715f2f0a13fc26309c777329dd51c8b4e8

Contents?: true

Size: 1.73 KB

Versions: 8

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

require_relative 'begin'
require_relative 'variables'
module DeepCover
  class Node
    # Singletons
    class SingletonLiteral < Node
      executed_loc_keys :expression
    end
    True = False = Nil = Self = SingletonLiteral

    # Atoms
    def self.atom(type)
      ::Class.new(Node) do
        has_child value: type
        executed_loc_keys :expression
      end
    end
    Sym = atom(::Symbol)
    Int = atom(::Integer)
    Float = atom(::Float)
    Complex = atom(::Complex)
    Rational = atom(::Rational)
    class Regopt < Node
      has_extra_children options: [::Symbol]
      executed_loc_keys :expression
    end

    class Str < Node
      has_child value: ::String

      def executed_loc_keys
        keys = [:expression, :heredoc_body, :heredoc_end]

        exp = expression
        keys.delete(:expression) if exp && exp.source !~ /\S/

        hd_body = loc_hash[:heredoc_body]
        keys.delete(:heredoc_body) if hd_body && hd_body.source !~ /\S/

        keys
      end
    end

    # Di-atomic
    class Range < Node
      has_child from: Node
      has_child to: Node
    end
    Erange = Irange = Range

    # Dynamic
    def self.has_evaluated_segments
      has_extra_children constituents: [Str, Begin, Ivar, Cvar, Gvar, Dstr, NthRef]
    end
    class DynamicLiteral < Node
      def executed_loc_keys
        if loc_hash[:heredoc_end]
          [:expression, :heredoc_end]
        else
          [:begin, :end]
        end
      end
    end
    Dsym = Dstr = DynamicLiteral
    DynamicLiteral.has_evaluated_segments

    class Regexp < Node
      has_evaluated_segments
      has_child option: Regopt
    end

    class Xstr < Node
      check_completion
      has_evaluated_segments
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
deep-cover-0.5.2 lib/deep_cover/node/literals.rb
deep-cover-0.5.1 lib/deep_cover/node/literals.rb
deep-cover-0.5.0 lib/deep_cover/node/literals.rb
deep-cover-0.4.0 lib/deep_cover/node/literals.rb
deep-cover-0.3.0 lib/deep_cover/node/literals.rb
deep-cover-0.2.0 lib/deep_cover/node/literals.rb
deep-cover-0.1.16 lib/deep_cover/node/literals.rb
deep-cover-0.1.15 lib/deep_cover/node/literals.rb