Class: Antlr4::Runtime::LexerPushModeAction

Inherits:
LexerAction
  • Object
show all
Defined in:
lib/antlr4/runtime/lexer_push_mode_action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode) ⇒ LexerPushModeAction

Returns a new instance of LexerPushModeAction


6
7
8
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 6

def initialize(mode)
  @mode = mode
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode


4
5
6
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 4

def mode
  @mode
end

Instance Method Details

#action_typeObject


10
11
12
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 10

def action_type
  LexerActionType::PUSH_MODE
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)

37
38
39
40
41
42
43
44
45
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 37

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

  @mode == other.mode
end

#execute(lexer) ⇒ Object


18
19
20
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 18

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

#hashObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 22

def hash
  return @_hash unless @_hash.nil?

  hash_code = MurmurHash.hash_int_int(action_type, mode)

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

#position_dependent?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 14

def position_dependent?
  false
end

#to_sObject


47
48
49
# File 'lib/antlr4/runtime/lexer_push_mode_action.rb', line 47

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