class RubyParserStuff::StackState

Attributes

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

Public Class Methods

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

Public Instance Methods

inspect() click to toggle source
# File lib/ruby_parser_extras.rb, line 1340
def inspect
  "StackState(#{@name}, #{@stack.inspect})"
end
is_in_state() click to toggle source
# File lib/ruby_parser_extras.rb, line 1344
def is_in_state
  @stack.last
end
lexpop() click to toggle source
# File lib/ruby_parser_extras.rb, line 1348
def lexpop
  warn "#{name}_stack.lexpop" 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 1356
def pop
  r = @stack.pop
  warn "#{name}_stack.pop" if debug
  @stack.push false if @stack.size == 0
  r
end
push(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 1363
def push val
  @stack.push val
  c = caller.first
  c = caller[1] if c =~ /expr_result/
  warn "#{name}_stack(push): #{val} at line #{c.clean_caller}" if debug
  nil
end
reset() click to toggle source
# File lib/ruby_parser_extras.rb, line 1335
def reset
  @stack = [false]
  warn "#{name}_stack(set): 0" if debug
end
restore(oldstate) click to toggle source
# File lib/ruby_parser_extras.rb, line 1377
def restore oldstate
  @stack.replace oldstate
end
store() click to toggle source
# File lib/ruby_parser_extras.rb, line 1371
def store
  result = @stack.dup
  @stack.replace [false]
  result
end