Class: LexerIndexedCustomAction

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

Overview

LexerActionExecutor#fixOffsetBeforeMatch.</p>

Instance Attribute Summary collapse

Attributes inherited from LexerAction

#actionType

Instance Method Summary collapse

Methods inherited from LexerAction

#eql?

Constructor Details

#initialize(_offset, _action) ⇒ LexerIndexedCustomAction

Returns a new instance of LexerIndexedCustomAction.



289
290
291
292
293
294
# File 'lib/antlr4/atn/LexerAction.rb', line 289

def initialize(_offset, _action)
    super(action.actionType)
    self.offset = _offset
    self.action = _action
    self.isPositionDependent = true
end

Instance Attribute Details

#actionObject

Constructs a new indexed custom action by associating a character offset with a LexerAction.

<p>Note: This class is only required for lexer actions for which LexerAction#isPositionDependent returns true.</p>

the token start index, at which the specified lexer action should be executed. input CharStream.

Parameters:

  • offset

    The offset into the input CharStream, relative to

  • action

    The lexer action to execute at a particular offset in the



288
289
290
# File 'lib/antlr4/atn/LexerAction.rb', line 288

def action
  @action
end

#isPositionDependentObject

Constructs a new indexed custom action by associating a character offset with a LexerAction.

<p>Note: This class is only required for lexer actions for which LexerAction#isPositionDependent returns true.</p>

the token start index, at which the specified lexer action should be executed. input CharStream.

Parameters:

  • offset

    The offset into the input CharStream, relative to

  • action

    The lexer action to execute at a particular offset in the



288
289
290
# File 'lib/antlr4/atn/LexerAction.rb', line 288

def isPositionDependent
  @isPositionDependent
end

#offsetObject

Constructs a new indexed custom action by associating a character offset with a LexerAction.

<p>Note: This class is only required for lexer actions for which LexerAction#isPositionDependent returns true.</p>

the token start index, at which the specified lexer action should be executed. input CharStream.

Parameters:

  • offset

    The offset into the input CharStream, relative to

  • action

    The lexer action to execute at a particular offset in the



288
289
290
# File 'lib/antlr4/atn/LexerAction.rb', line 288

def offset
  @offset
end

Instance Method Details

#==(other) ⇒ Object



307
308
309
310
# File 'lib/antlr4/atn/LexerAction.rb', line 307

def ==(other)
    self.equal?(other) or other.kind_of?(LexerIndexedCustomAction) \
        and self.offset == other.offset and self.action == other.action
end

#execute(lexer) ⇒ Object

<p>This method calls #execute on the result of #getAction using the provided lexer.</p>



298
299
300
301
# File 'lib/antlr4/atn/LexerAction.rb', line 298

def execute(lexer)
    # assume the input stream position was properly set by the calling code
    self.action.execute(lexer)
end

#hashObject



303
304
305
# File 'lib/antlr4/atn/LexerAction.rb', line 303

def hash
    "#{self.actionType}#{self.offset}#{self.action}".hash
end