Class: LexerChannelAction

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

Overview

Lexer#setChannel with the assigned channel.

Instance Attribute Summary collapse

Attributes inherited from LexerAction

#actionType, #isPositionDependent

Instance Method Summary collapse

Methods inherited from LexerAction

#eql?

Constructor Details

#initialize(_channel) ⇒ LexerChannelAction

Returns a new instance of LexerChannelAction.



244
245
246
247
# File 'lib/antlr4/atn/LexerAction.rb', line 244

def initialize(_channel)
    super(LexerActionType::CHANNEL)
    self.channel = _channel
end

Instance Attribute Details

#channelObject

Constructs a new channel action with the specified channel value.

Parameters:

  • channel

    The channel value to pass to Lexer#setChannel.



243
244
245
# File 'lib/antlr4/atn/LexerAction.rb', line 243

def channel
  @channel
end

Instance Method Details

#==(other) ⇒ Object



258
259
260
261
# File 'lib/antlr4/atn/LexerAction.rb', line 258

def ==(other)
    self.equal?(other) or other.kind_of?(LexerChannelAction) \
      and self.channel == other.channel
end

#execute(lexer) ⇒ Object

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



251
252
253
# File 'lib/antlr4/atn/LexerAction.rb', line 251

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

#hashObject



254
255
256
# File 'lib/antlr4/atn/LexerAction.rb', line 254

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

#to_sObject



263
264
265
# File 'lib/antlr4/atn/LexerAction.rb', line 263

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