1<?php
2
3declare(strict_types=1);
4
5namespace Antlr\Antlr4\Runtime\Atn\Transitions;
6
7use Antlr\Antlr4\Runtime\Atn\SemanticContexts\PrecedencePredicate;
8use Antlr\Antlr4\Runtime\Atn\States\ATNState;
9
10class PrecedencePredicateTransition extends AbstractPredicateTransition
11{
12    /** @var int */
13    public $precedence;
14
15    public function __construct(ATNState $target, int $precedence)
16    {
17        parent::__construct($target);
18
19        $this->precedence = $precedence;
20    }
21
22    public function matches(int $symbol, int $minVocabSymbol, int $maxVocabSymbol) : bool
23    {
24        return false;
25    }
26
27    public function getPredicate() : PrecedencePredicate
28    {
29        return new PrecedencePredicate($this->precedence);
30    }
31
32    /**
33     * {@inheritdoc}
34     */
35    public function isEpsilon() : bool
36    {
37        return true;
38    }
39
40    public function getSerializationType() : int
41    {
42        return self::PRECEDENCE;
43    }
44
45    public function equals(object $other) : bool
46    {
47        if ($this === $other) {
48            return true;
49        }
50
51        return $other instanceof self
52            && $this->precedence === $other->precedence
53            && $this->target->equals($other->target);
54    }
55
56    public function __toString() : string
57    {
58        return $this->precedence . ' >= _p';
59    }
60}
61