ruleIndex = $ruleIndex; $this->actionIndex = $actionIndex; } /** * Gets the rule index to use for calls to {@see Recognizer::action()}. * * @return int The rule index for the custom action. */ public function getRuleIndex() : int { return $this->ruleIndex; } /** * Gets the action index to use for calls to {@see Recognizer::action()}. * * @return int The action index for the custom action. */ public function getActionIndex() : int { return $this->actionIndex; } /** * {@inheritdoc} * * @return int This method returns {@see LexerActionType::CUSTOM()}. */ public function getActionType() : int { return LexerActionType::CUSTOM; } /** * Gets whether the lexer action is position-dependent. Position-dependent * actions may have different semantics depending on the {@see CharStream} * index at the time the action is executed. * * Custom actions are position-dependent since they may represent a * user-defined embedded action which makes calls to methods like * {@see Lexer::getText()}. * * @return bool This method returns `true`. */ public function isPositionDependent() : bool { return true; } /** * {@inheritdoc} * * Custom actions are implemented by calling {@see Lexer::action()} with the * appropriate rule and action indexes. */ public function execute(Lexer $lexer) : void { $lexer->action(null, $this->ruleIndex, $this->actionIndex); } public function hashCode() : int { return Hasher::hash($this->getActionType(), $this->ruleIndex, $this->actionIndex); } public function equals(object $other) : bool { if ($this === $other) { return true; } if (!$other instanceof self) { return false; } return $this->ruleIndex === $other->ruleIndex && $this->actionIndex === $other->actionIndex; } }