Class: LexerCustomAction

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

Overview

command argument could not be evaluated when the grammar was compiled.</p>

Instance Attribute Summary collapse

Attributes inherited from LexerAction

#actionType

Instance Method Summary collapse

Methods inherited from LexerAction

#eql?

Constructor Details

#initialize(rule_index, action_index) ⇒ LexerCustomAction

Returns a new instance of LexerCustomAction.



217
218
219
220
221
222
# File 'lib/antlr4/atn/LexerAction.rb', line 217

def initialize(rule_index, action_index)
    super(LexerActionType::CUSTOM)
    @ruleIndex = rule_index
    @actionIndex = action_index
    @isPositionDependent = true
end

Instance Attribute Details

#actionIndexObject

Constructs a custom lexer action with the specified rule and action indexes.

Recognizer#action. Recognizer#action. /

Parameters:

  • ruleIndex

    The rule index to use for calls to

  • actionIndex

    The action index to use for calls to



216
217
218
# File 'lib/antlr4/atn/LexerAction.rb', line 216

def actionIndex
  @actionIndex
end

#isPositionDependentObject

Constructs a custom lexer action with the specified rule and action indexes.

Recognizer#action. Recognizer#action. /

Parameters:

  • ruleIndex

    The rule index to use for calls to

  • actionIndex

    The action index to use for calls to



216
217
218
# File 'lib/antlr4/atn/LexerAction.rb', line 216

def isPositionDependent
  @isPositionDependent
end

#ruleIndexObject

Constructs a custom lexer action with the specified rule and action indexes.

Recognizer#action. Recognizer#action. /

Parameters:

  • ruleIndex

    The rule index to use for calls to

  • actionIndex

    The action index to use for calls to



216
217
218
# File 'lib/antlr4/atn/LexerAction.rb', line 216

def ruleIndex
  @ruleIndex
end

Instance Method Details

#==(other) ⇒ Object



232
233
234
235
# File 'lib/antlr4/atn/LexerAction.rb', line 232

def ==( other)
    self.equal?(other) or other.kind_of?( LexerCustomAction) \
    and self.ruleIndex == other.ruleIndex and self.actionIndex == other.actionIndex
end

#execute(lexer) ⇒ Object

<p>Custom actions are implemented by calling Lexer#action with the appropriate rule and action indexes.</p>



225
226
227
# File 'lib/antlr4/atn/LexerAction.rb', line 225

def execute(lexer)
    lexer.action(nil, self.ruleIndex, self.actionIndex)
end

#hashObject



228
229
230
# File 'lib/antlr4/atn/LexerAction.rb', line 228

def hash
   "#{self.actionType}#{self.ruleIndex}#{self.actionIndex}".hash
end