Class: LexerPushModeAction

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

Overview

Implements the pushMode lexer action by calling Lexer#pushMode with the assigned mode.

Instance Attribute Summary collapse

Attributes inherited from LexerAction

#actionType, #isPositionDependent

Instance Method Summary collapse

Methods inherited from LexerAction

#eql?

Constructor Details

#initialize(_mode) ⇒ LexerPushModeAction

Returns a new instance of LexerPushModeAction.



93
94
95
96
# File 'lib/antlr4/atn/LexerAction.rb', line 93

def initialize(_mode)
    super(LexerActionType::PUSH_MODE)
    self.mode = _mode
end

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



92
93
94
# File 'lib/antlr4/atn/LexerAction.rb', line 92

def mode
  @mode
end

Instance Method Details

#==(other) ⇒ Object



108
109
110
# File 'lib/antlr4/atn/LexerAction.rb', line 108

def ==(other)
    self.equal?(other) or other.kind_of?(LexerPushModeAction) and self.mode == other.mode
end

#execute(lexer) ⇒ Object

<p>This action is implemented by calling Lexer#pushMode with the value provided by #getMode.</p>



100
101
102
# File 'lib/antlr4/atn/LexerAction.rb', line 100

def execute(lexer)
    lexer.pushMode(self.mode)
end

#hashObject



104
105
106
# File 'lib/antlr4/atn/LexerAction.rb', line 104

def hash
    "#{self.actionType}#{self.mode}".hash
end

#to_sObject



112
113
114
# File 'lib/antlr4/atn/LexerAction.rb', line 112

def to_s
    "pushMode(#{self.mode})"
end