Sha256: 7df2d38126da9e62293e18a58722aeee09e96f913d4278d0fa715a459d10a4a4

Contents?: true

Size: 946 Bytes

Versions: 5

Compression:

Stored size: 946 Bytes

Contents

module Antlr4::Runtime

  class LexerChannelAction < LexerAction
    attr_reader :channel

    def initialize(channel)
      @channel = channel
    end

    def action_type
      LexerActionType::CHANNEL
    end

    def position_dependent?
      false
    end

    def execute(lexer)
      lexer.setChannel(@channel)
    end

    def hash
      return @_hash unless @_hash.nil?

      hash_code = RumourHash.calculate([action_type.ordinal, channel])

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

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

      @channel == other.channel
    end

    def to_s
      'channel(' << @channel.to_s << ')'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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