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

Version Path
cybrid_api_bank_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_id_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_bank_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_organization_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_id_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_id_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_bank_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_organization_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_bank_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_organization_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_id_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_bank_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_organization_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_id_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_bank_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_organization_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_id_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_organization_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_bank_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb
cybrid_api_id_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb