Class: LexerModeAction

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

Overview

Implements the mode lexer action by calling Lexer#mode 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) ⇒ LexerModeAction

Returns a new instance of LexerModeAction.



174
175
176
177
# File 'lib/antlr4/atn/LexerAction.rb', line 174

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

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



173
174
175
# File 'lib/antlr4/atn/LexerAction.rb', line 173

def mode
  @mode
end

Instance Method Details

#==(other) ⇒ Object



189
190
191
# File 'lib/antlr4/atn/LexerAction.rb', line 189

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

#execute(lexer) ⇒ Object

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



181
182
183
# File 'lib/antlr4/atn/LexerAction.rb', line 181

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

#hashObject



185
186
187
# File 'lib/antlr4/atn/LexerAction.rb', line 185

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

#to_sObject



193
194
195
# File 'lib/antlr4/atn/LexerAction.rb', line 193

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