1<?php
2
3declare(strict_types=1);
4
5namespace Antlr\Antlr4\Runtime\Atn\Actions;
6
7use Antlr\Antlr4\Runtime\Comparison\Hasher;
8use Antlr\Antlr4\Runtime\Lexer;
9
10/**
11 * Implements the `more` lexer action by calling {@see Lexer::more()}.
12 *
13 * The `more` command does not have any parameters, so this action is
14 * implemented as a singleton instance exposed by {@see LexerMoreAction::INSTANCE()}.
15 *
16 * @author Sam Harwell
17 */
18final class LexerMoreAction implements LexerAction
19{
20    /**
21     * Provides a singleton instance of this parameterless lexer action.
22     */
23    public static function instance() : self
24    {
25        static $instance;
26
27        return $instance = $instance ?? new self();
28    }
29
30    /**
31     * {@inheritdoc}
32     *
33     * @return int This method returns {@see LexerActionType::MORE}.
34     */
35    public function getActionType() : int
36    {
37        return LexerActionType::MORE;
38    }
39
40    /**
41     * {@inheritdoc}
42     *
43     * @return bool This method returns `false`.
44     */
45    public function isPositionDependent() : bool
46    {
47        return false;
48    }
49
50    /**
51     * {@inheritdoc}
52     *
53     * This action is implemented by calling {@see Lexer::more()}.
54     */
55    public function execute(Lexer $lexer) : void
56    {
57        $lexer->more();
58    }
59
60    public function hashCode() : int
61    {
62        return Hasher::hash($this->getActionType());
63    }
64
65    public function equals(object $other) : bool
66    {
67        if ($this === $other) {
68            return true;
69        }
70
71        return $other instanceof self;
72    }
73
74    public function __toString() : string
75    {
76        return 'more';
77    }
78}
79