1<?php 2 3declare(strict_types=1); 4 5namespace Antlr\Antlr4\Runtime\Atn\Transitions; 6 7use Antlr\Antlr4\Runtime\Atn\States\ATNState; 8 9final class EpsilonTransition extends Transition 10{ 11 /** @var int */ 12 private $outermostPrecedenceReturn; 13 14 public function __construct(ATNState $target, int $outermostPrecedenceReturn = -1) 15 { 16 parent::__construct($target); 17 18 $this->outermostPrecedenceReturn = $outermostPrecedenceReturn; 19 } 20 21 /** 22 * @return int The rule index of a precedence rule for which this transition 23 * is returning from, where the precedence value is 0; otherwise, 24 * -1. 25 * 26 * @see ATNConfig::isPrecedenceFilterSuppressed() 27 * @see ParserATNSimulator::applyPrecedenceFilter() 28 */ 29 public function getOutermostPrecedenceReturn() : int 30 { 31 return $this->outermostPrecedenceReturn; 32 } 33 34 public function matches(int $symbol, int $minVocabSymbol, int $maxVocabSymbol) : bool 35 { 36 return false; 37 } 38 39 /** 40 * {@inheritdoc} 41 */ 42 public function isEpsilon() : bool 43 { 44 return true; 45 } 46 47 public function getSerializationType() : int 48 { 49 return self::EPSILON; 50 } 51 52 public function equals(object $other) : bool 53 { 54 if ($this === $other) { 55 return true; 56 } 57 58 return $other instanceof self 59 && $this->outermostPrecedenceReturn === $other->outermostPrecedenceReturn 60 && $this->target->equals($other->target); 61 } 62 63 public function __toString() : string 64 { 65 return 'epsilon'; 66 } 67} 68