Sha256: 7063f1f3627b3b3fa693afba3ad63ce5f4f9885677be08900b09819d9234ad8a

Contents?: true

Size: 717 Bytes

Versions: 6942

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

module Parser
  # Stack that holds names of current arguments,
  # i.e. while parsing
  #   def m1(a = (def m2(b = def m3(c = 1); end); end)); end
  #                                   ^
  # stack is [:a, :b, :c]
  #
  # Emulates `p->cur_arg` in MRI's parse.y
  #
  # @api private
  #
  class CurrentArgStack
    attr_reader :stack

    def initialize
      @stack = []
      freeze
    end

    def empty?
      @stack.size == 0
    end

    def push(value)
      @stack << value
    end

    def set(value)
      @stack[@stack.length - 1] = value
    end

    def pop
      @stack.pop
    end

    def reset
      @stack.clear
    end

    def top
      @stack.last
    end
  end
end

Version data entries

6,942 entries across 6,933 versions & 41 rubygems

Version Path
ory-client-0.0.1.alpha109 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
avalara_sdk-2.4.26 vendor/bundle/ruby/2.6.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha108 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-oathkeeper-client-0.38.23.beta1 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-oathkeeper-client-0.38.22.beta1 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha107 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-hydra-client-1.11.7 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha106 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-hydra-client-1.11.6 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-keto-client-0.8.0.alpha1 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha105 vendor/bundle/ruby/2.5.0/gems/parser-3.1.1.0/lib/parser/current_arg_stack.rb
parser-3.1.1.0 lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha104 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha103 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-hydra-client-1.11.5 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha101 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha100 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-hydra-client-1.11.4 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha99 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb
ory-client-0.0.1.alpha98 vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/current_arg_stack.rb