Sha256: 1d88c8c7a52f295ebde016f5d728d373351cb023072ab34bf256e21305dab009
Contents?: true
Size: 509 Bytes
Versions: 2
Compression:
Stored size: 509 Bytes
Contents
module Parser class Lexer::StackState def initialize(name) @name = name.freeze @stack = 0 end def push(bit) bit_value = bit ? 1 : 0 @stack = (@stack << 1) | bit_value bit end def pop bit_value = @stack & 1 @stack >>= 1 bit_value == 1 end def lexpop push(pop || pop) end def active? @stack[0] == 1 end def to_s "[#{@stack.to_s(2)} <= #{@name}]" end alias inspect to_s end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
parser-0.9.1 | lib/parser/lexer/stack_state.rb |
parser-0.9.0 | lib/parser/lexer/stack_state.rb |