Class: Antlr4::Runtime::LexerCustomAction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule_index, action_index) ⇒ LexerCustomAction

Returns a new instance of LexerCustomAction.



7
8
9
10
# File 'lib/antlr4/runtime/lexer_custom_action.rb', line 7

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

Instance Attribute Details

#action_indexObject (readonly)

Returns the value of attribute action_index.



5
6
7
# File 'lib/antlr4/runtime/lexer_custom_action.rb', line 5

def action_index
  @action_index
end

#rule_indexObject (readonly)

Returns the value of attribute rule_index.



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

def rule_index
  @rule_index
end

Instance Method Details

#action_typeObject



12
13
14
# File 'lib/antlr4/runtime/lexer_custom_action.rb', line 12

def action_type
  LexerActionType::CUSTOM
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
# File 'lib/antlr4/runtime/lexer_custom_action.rb', line 40

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

#execute(lexer) ⇒ Object



20
21
22
# File 'lib/antlr4/runtime/lexer_custom_action.rb', line 20

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

#hashObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/antlr4/runtime/lexer_custom_action.rb', line 24

def hash
  return @_hash unless @_hash.nil?

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

  unless @_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

#position_dependent?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/antlr4/runtime/lexer_custom_action.rb', line 16

def position_dependent?
  true
end