class Parser::Lexer::StackState

Public Class Methods

new(name) click to toggle source
# File lib/parser/lexer/stack_state.rb, line 5
def initialize(name)
  @name  = name.freeze
  clear
end

Public Instance Methods

active?() click to toggle source
# File lib/parser/lexer/stack_state.rb, line 33
def active?
  @stack[0] == 1
end
clear() click to toggle source
# File lib/parser/lexer/stack_state.rb, line 10
def clear
  @stack = 0
end
empty?() click to toggle source
# File lib/parser/lexer/stack_state.rb, line 37
def empty?
  @stack == 0
end
inspect()
Alias for: to_s
lexpop() click to toggle source
# File lib/parser/lexer/stack_state.rb, line 28
def lexpop
  @stack = ((@stack >> 1) | (@stack & 1))
  @stack[0] == 1
end
pop() click to toggle source
# File lib/parser/lexer/stack_state.rb, line 21
def pop
  bit_value = @stack & 1
  @stack  >>= 1

  bit_value == 1
end
push(bit) click to toggle source
# File lib/parser/lexer/stack_state.rb, line 14
def push(bit)
  bit_value = bit ? 1 : 0
  @stack = (@stack << 1) | bit_value

  bit
end
to_s() click to toggle source
# File lib/parser/lexer/stack_state.rb, line 41
def to_s
  "[#{@stack.to_s(2)} <= #{@name}]"
end
Also aliased as: inspect