Class: LexerTypeAction

Inherits:
LexerAction show all
Defined in:
lib/antlr4/atn/LexerAction.rb

Overview

Implements the type lexer action by calling Lexer#setType with the assigned type.

Instance Attribute Summary collapse

Attributes inherited from LexerAction

#actionType, #isPositionDependent

Instance Method Summary collapse

Methods inherited from LexerAction

#eql?

Constructor Details

#initialize(_type) ⇒ LexerTypeAction

Returns a new instance of LexerTypeAction.



68
69
70
71
# File 'lib/antlr4/atn/LexerAction.rb', line 68

def initialize(_type)
    super(LexerActionType::TYPE)
    self.type = _type
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



67
68
69
# File 'lib/antlr4/atn/LexerAction.rb', line 67

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



80
81
82
# File 'lib/antlr4/atn/LexerAction.rb', line 80

def ==(other) 
    self.equal?(other) or other.kind_of?(LexerTypeAction) and self.type == other.type
end

#execute(lexer) ⇒ Object



72
73
74
# File 'lib/antlr4/atn/LexerAction.rb', line 72

def execute(lexer)
    lexer.type = self.type
end

#hashObject



76
77
78
# File 'lib/antlr4/atn/LexerAction.rb', line 76

def hash
    return "#{self.actionType}#{self.type}".hash
end

#to_sObject



83
84
85
# File 'lib/antlr4/atn/LexerAction.rb', line 83

def to_s
    return "type(#{self.type})"
end