Sha256: ab42de2441d6f37f106226462c9f258d71c221341616d7bbd29a31275560cb38

Contents?: true

Size: 510 Bytes

Versions: 12

Compression:

Stored size: 510 Bytes

Contents

# frozen_string_literal: true

module Parser

  class Lexer::MaxNumparamStack
    def initialize
      @stack = []
    end

    def cant_have_numparams!
      set(-1)
    end

    def can_have_numparams?
      top >= 0
    end

    def register(numparam)
      set( [top, numparam].max )
    end

    def top
      @stack.last
    end

    def push
      @stack.push(0)
    end

    def pop
      @stack.pop
    end

    private

    def set(value)
      @stack.pop
      @stack.push(value)
    end
  end

end

Version data entries

12 entries across 8 versions & 2 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/lexer/max_numparam_stack.rb
parser-2.6.5.0 lib/parser/lexer/max_numparam_stack.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer/max_numparam_stack.rb
parser-2.6.4.1 lib/parser/lexer/max_numparam_stack.rb
parser-2.6.4.0 lib/parser/lexer/max_numparam_stack.rb