offset = $offset; $this->action = $action; } /** * Gets the location in the input {@see CharStream} at which the lexer * action should be executed. The value is interpreted as an offset relative * to the token start index. * * @return int The location in the input {@see CharStream} at which the lexer * action should be executed. */ public function getOffset() : int { return $this->offset; } /** * Gets the lexer action to execute. * * @return LexerAction A {@see LexerAction} object which executes the lexer action. */ public function getAction() : LexerAction { return $this->action; } /** * {@inheritdoc} * * @return int This method returns the result of calling * {@see LexerIndexedCustomAction::getActionType()} on the * {@see LexerAction} returned by * {@see LexerIndexedCustomAction::getAction()}. */ public function getActionType() : int { return $this->action->getActionType(); } /** * {@inheritdoc} * * @return bool This method returns `true`. */ public function isPositionDependent() : bool { return true; } /** * {@inheritdoc} * * This method calls {@see LexerIndexedCustomAction::execute()} on the result * of {@see LexerIndexedCustomAction::getAction()} using the provided `lexer`. */ public function execute(Lexer $lexer) : void { // assume the input stream position was properly set by the calling code $this->action->execute($lexer); } public function hashCode() : int { return Hasher::hash($this->getActionType(), $this->offset, $this->action); } public function equals(object $other) : bool { if ($this === $other) { return true; } if (!$other instanceof self) { return false; } return $this->offset === $other->offset && $this->action->equals($other->action); } }