class Parser::CurrentArgStack

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

Attributes

stack[R]

Public Class Methods

new() click to toggle source
# File lib/parser/current_arg_stack.rb, line 16
def initialize
  @stack = []
  freeze
end

Public Instance Methods

empty?() click to toggle source
# File lib/parser/current_arg_stack.rb, line 21
def empty?
  @stack.size == 0
end
pop() click to toggle source
# File lib/parser/current_arg_stack.rb, line 33
def pop
  @stack.pop
end
push(value) click to toggle source
# File lib/parser/current_arg_stack.rb, line 25
def push(value)
  @stack << value
end
reset() click to toggle source
# File lib/parser/current_arg_stack.rb, line 37
def reset
  @stack.clear
end
set(value) click to toggle source
# File lib/parser/current_arg_stack.rb, line 29
def set(value)
  @stack[@stack.length - 1] = value
end
top() click to toggle source
# File lib/parser/current_arg_stack.rb, line 41
def top
  @stack.last
end