Lines Matching refs:state

270         // state instances have been initialized
338 foreach ($atn->states as $state) {
339 if (!$state instanceof RuleStopState) {
343 $atn->ruleToStopState[$state->ruleIndex] = $state;
344 $atn->ruleToStartState[$state->ruleIndex]->stopState = $state;
409 foreach ($atn->states as $state) {
410 foreach ($state->getTransitions() as $t) {
427 foreach ($atn->states as $state) {
428 if ($state instanceof BlockStartState) {
429 // we need to know the end state to set its start state
430 if ($state->endState === null) {
434 // block end states can only be associated to a single block start state
435 if ($state->endState->startState !== null) {
439 $state->endState->startState = $state;
442 if ($state instanceof PlusLoopbackState) {
443 foreach ($state->getTransitions() as $t) {
447 $target->loopBackState = $state;
450 } elseif ($state instanceof StarLoopbackState) {
451 foreach ($state->getTransitions() as $t) {
455 $target->loopBackState = $state;
536 foreach ($atn->states as $state) {
537 if ($this->stateIsEndStateFor($state, $idx)) {
538 $endState = $state;
540 if (!$state instanceof LoopEndState) {
541 throw new \RuntimeException('Unexpected state type.');
544 if ($state->loopBackState === null) {
545 throw new \RuntimeException('Unexpected null loop back state.');
548 $excludeTransition = $state->loopBackState->getTransition(0);
555 throw new \RuntimeException('Couldn\'t identify final state of the precedence rule prefix section.');
561 // all non-excluded transitions that currently target end state need to target blockEnd instead
563 foreach ($atn->states as $state) {
564 foreach ($state->getTransitions() as $transition) {
575 // all transitions leaving the rule start state need to leave blockStart instead
588 throw new \RuntimeException('Unexpected null end state.');
599 private function stateIsEndStateFor(ATNState $state, int $idx) : ?ATNState
601 if ($state->ruleIndex !== $idx) {
605 if (!$state instanceof StarLoopEntryState) {
609 $maybeLoopEndState = $state->getTransition($state->getNumberOfTransitions() - 1)->target;
617 return $state;
632 foreach ($atn->states as $state) {
633 if (!$state instanceof StarLoopEntryState) {
637 // We analyze the ATN to determine if this ATN decision state is the
640 if ($atn->ruleToStartState[$state->ruleIndex]->isLeftRecursiveRule) {
641 $maybeLoopEndState = $state->getTransition($state->getNumberOfTransitions() - 1)->target;
646 $state->isPrecedenceDecision = true;
660 foreach ($atn->states as $state) {
661 $this->checkCondition($state->epsilonOnlyTransitions || $state->getNumberOfTransitions() <= 1);
664 case $state instanceof PlusBlockStartState:
665 $this->checkCondition($state->loopBackState !== null);
669 case $state instanceof StarLoopEntryState:
670 $this->checkCondition($state->loopBackState !== null);
671 $this->checkCondition($state->getNumberOfTransitions() === 2);
673 if ($state->getTransition(0)->target instanceof StarBlockStartState) {
674 $this->checkCondition($state->getTransition(1)->target instanceof LoopEndState);
675 $this->checkCondition(!$state->nonGreedy);
676 } elseif ($state->getTransition(0)->target instanceof LoopEndState) {
677 $this->checkCondition($state->getTransition(1)->target instanceof StarBlockStartState);
678 $this->checkCondition($state->nonGreedy);
685 case $state instanceof StarLoopbackState:
686 $this->checkCondition($state->getNumberOfTransitions() === 1);
687 $this->checkCondition($state->getTransition(0)->target instanceof StarLoopEntryState);
691 case $state instanceof LoopEndState:
692 $this->checkCondition($state->loopBackState !== null);
696 case $state instanceof RuleStartState:
697 $this->checkCondition($state->stopState !== null);
701 case $state instanceof BlockStartState:
702 $this->checkCondition($state->endState !== null);
706 case $state instanceof BlockEndState:
707 $this->checkCondition($state->startState !== null);
711 case $state instanceof DecisionState:
712 $this->checkCondition($state->getNumberOfTransitions() <= 1 || $state->decision >= 0);
717 $this->checkCondition($state->getNumberOfTransitions() <= 1 || $state instanceof RuleStopState);
887 'The specified state type %d is not valid.',