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
cybrid_api_id_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_organization_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_bank_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_organization_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_id_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_bank_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_id_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_organization_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_bank_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_id_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_organization_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_bank_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_id_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_organization_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_id_ruby-0.123.137 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_organization_ruby-0.123.137 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_bank_ruby-0.123.137 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb
cybrid_api_organization_ruby-0.123.135 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb