Sha256: febf7914fc8187758e1cc3425779f6a55f9849f3ed4c7361e535394da73e7df8

Contents?: true

Size: 882 Bytes

Versions: 5

Compression:

Stored size: 882 Bytes

Contents

module Antlr4::Runtime

  class LexerModeAction < LexerAction
    attr_reader :mode

    def initialize(mode)
      @mode = mode
    end

    def action_type
      LexerActionType::MODE
    end

    def position_dependent?
      false
    end

    def execute(lexer)
      lexer.mode(@mode)
    end

    def hash
      return @_hash unless @_hash.nil?

      hash_code = RumourHash.calculate([action_type, mode])

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

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

      @mode == other.mode
    end

    def to_s
      'mode(' << @mode << ')'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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