Sha256: 7f09f646a4ee4dc0e7187d9a8dcf70295061c071e0c4c6916887b3d80375264a

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module Antlr4::Runtime

  class LexerCustomAction < LexerAction
    attr_reader :rule_index
    attr_reader :action_index

    def initialize(rule_index, action_index)
      @rule_index = rule_index
      @action_index = action_index
    end

    def action_type
      LexerActionType::CUSTOM
    end

    def position_dependent?
      true
    end

    def execute(lexer)
      lexer.action(nil, @rule_index, @action_index)
    end

    def hash
      return @_hash unless @_hash.nil?

      hash_code = RumourHash.calculate([action_type, rule_index, action_index])

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

      @_hash = hash_code
    end

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

      @rule_index == other.rule_index && @action_index == other.action_index
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
antlr4-runtime-0.2.8 lib/antlr4/runtime/lexer_custom_action.rb
antlr4-runtime-0.2.7 lib/antlr4/runtime/lexer_custom_action.rb
antlr4-runtime-0.2.6 lib/antlr4/runtime/lexer_custom_action.rb
antlr4-runtime-0.2.5 lib/antlr4/runtime/lexer_custom_action.rb
antlr4-runtime-0.2.4 lib/antlr4/runtime/lexer_custom_action.rb