1<?php 2 3declare(strict_types=1); 4 5namespace Antlr\Antlr4\Runtime\Atn\Transitions; 6 7use Antlr\Antlr4\Runtime\Atn\States\ATNState; 8use Antlr\Antlr4\Runtime\Atn\States\RuleStartState; 9 10final class RuleTransition extends Transition 11{ 12 /** 13 * Ptr to the rule definition object for this rule ref. 14 * No Rule object at runtime. 15 * 16 * @var int 17 */ 18 public $ruleIndex; 19 20 /** @var int */ 21 public $precedence; 22 23 /** 24 * What node to begin computations following ref to rule 25 * 26 * @var ATNState 27 */ 28 public $followState; 29 30 public function __construct(RuleStartState $ruleStart, int $ruleIndex, int $precedence, ATNState $followState) 31 { 32 parent::__construct($ruleStart); 33 34 $this->ruleIndex = $ruleIndex; 35 $this->precedence = $precedence; 36 $this->followState = $followState; 37 } 38 39 public function matches(int $symbol, int $minVocabSymbol, int $maxVocabSymbol) : bool 40 { 41 return false; 42 } 43 44 /** 45 * {@inheritdoc} 46 */ 47 public function isEpsilon() : bool 48 { 49 return true; 50 } 51 52 public function getSerializationType() : int 53 { 54 return self::RULE; 55 } 56 57 public function equals(object $other) : bool 58 { 59 if ($this === $other) { 60 return true; 61 } 62 63 return $other instanceof self 64 && $this->ruleIndex === $other->ruleIndex 65 && $this->precedence === $other->precedence 66 && $this->target->equals($other->target); 67 } 68 69 public function __toString() : string 70 { 71 return \sprintf('rule_%d:%d,%s', $this->ruleIndex, $this->precedence, $this->followState); 72 } 73} 74