Sha256: 6c4b455a2961afcfa57e2508d2d2f927d9f1b509c6bf3b6796a2de9b9bcdde59

Contents?: true

Size: 661 Bytes

Versions: 7011

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

7,011 entries across 6,988 versions & 50 rubygems

Version Path
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
parser-2.6.5.0 lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/stack_state.rb
parser-2.6.4.1 lib/parser/lexer/stack_state.rb
parser-2.6.4.0 lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/lexer/stack_state.rb
parser-2.6.3.0 lib/parser/lexer/stack_state.rb