Sha256: 6c4b455a2961afcfa57e2508d2d2f927d9f1b509c6bf3b6796a2de9b9bcdde59
Contents?: true
Size: 661 Bytes
Versions: 6966
Compression:
Stored size: 661 Bytes
Contents
# frozen_string_literal: true 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 @stack = ((@stack >> 1) | (@stack & 1)) @stack[0] == 1 end def active? @stack[0] == 1 end def empty? @stack == 0 end def to_s "[#{@stack.to_s(2)} <= #{@name}]" end alias inspect to_s end end
Version data entries
6,966 entries across 6,943 versions & 49 rubygems