Sha256: d47930238fbbf9562f9c1e34cd9085b00c9c2e643917278b915e3bf2c4dc60ca

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

module Antlr4::Runtime

  class LexerIndexedCustomAction < LexerAction
    attr_reader :action
    attr_reader :offset

    def initialize(offset, action)
      @offset = offset
      @action = action
    end

    def action_type
      @action.action_type
    end

    def position_dependent?
      true
    end

    def execute(lexer) # assume the input stream position was properly set by the calling code
      @action.execute(lexer)
    end

    def hash
      return @_hash unless @_hash.nil?

      hash_code = MurmurHash.hash_int_obj(offset, action)

      if !@_hash.nil?
        if hash_code == @_hash
          puts 'Same hash_code for LexerIndexedCustomAction'
        else
          puts 'Different hash_code for LexerIndexedCustomAction'
        end
      end
      @_hash = hash_code
    end

    def eql?(other)
      if other == self
        return true
      else
        return false unless other.is_a? LexerIndexedCustomAction
      end

      @offset == other.offset && @action == other.action
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
antlr4-runtime-0.2.3 lib/antlr4/runtime/lexer_indexed_custom_action.rb
antlr4-runtime-0.2.2 lib/antlr4/runtime/lexer_indexed_custom_action.rb
antlr4-runtime-0.2.1 lib/antlr4/runtime/lexer_indexed_custom_action.rb
antlr4-runtime-0.2.0 lib/antlr4/runtime/lexer_indexed_custom_action.rb
antlr4-runtime-0.1.0 lib/antlr4/runtime/lexer_indexed_custom_action.rb