Sha256: 9a839ee45e263990f639fab63d6b4abdac52f32340c386543dee38d25849c6e2
Contents?: true
Size: 544 Bytes
Versions: 101
Compression:
Stored size: 544 Bytes
Contents
module Parser class Lexer::StackState def initialize(name) @name = name.freeze clear end def clear @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
101 entries across 101 versions & 5 rubygems
Version | Path |
---|---|
parser-0.9.2 | lib/parser/lexer/stack_state.rb |