class RubyParserStuff::StackState

Attributes

debug[RW]
name[R]
stack[R]

Public Class Methods

new(name) click to toggle source
# File lib/ruby_parser_extras.rb, line 1312
def initialize(name)
  @name = name
  @stack = [false]
  @debug = false
end

Public Instance Methods

inspect() click to toggle source
# File lib/ruby_parser_extras.rb, line 1318
def inspect
  "StackState(#{@name}, #{@stack.inspect})"
end
is_in_state() click to toggle source
# File lib/ruby_parser_extras.rb, line 1322
def is_in_state
  p :stack_is_in_state => [name, @stack.last, caller.first] if debug
  @stack.last
end
lexpop() click to toggle source
# File lib/ruby_parser_extras.rb, line 1327
def lexpop
  p :stack_lexpop => caller.first if debug
  raise if @stack.size == 0
  a = @stack.pop
  b = @stack.pop
  @stack.push(a || b)
end
pop() click to toggle source
# File lib/ruby_parser_extras.rb, line 1335
def pop
  r = @stack.pop
  p :stack_pop => [name, r, @stack, caller.first] if debug
  @stack.push false if @stack.size == 0
  r
end
push(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 1342
def push val
  @stack.push val
  p :stack_push => [name, @stack, caller.first] if debug
  nil
end
restore(oldstate) click to toggle source
# File lib/ruby_parser_extras.rb, line 1354
def restore oldstate
  @stack.replace oldstate
end
store() click to toggle source
# File lib/ruby_parser_extras.rb, line 1348
def store
  result = @stack.dup
  @stack.replace [false]
  result
end