Lines Matching refs:state

45  * requests go through the DFA first. If they reach a state without an edge for
47 * complete the DFA path for the current input (until it finds a conflict state
48 * or uniquely predicting state).
70 * The next time we reach this DFA state with an SLL conflict, through DFA
79 * of visible predicates from the ATN start state changes depending on the
106 * dip into the outer context by falling off the end of the decision state rule,
137 * evaluation until it reaches and accept state. This allows us to cache the SLL
139 * closure, the DFA state configuration sets would be different and we couldn't
142 * When building a DFA accept state during ATN simulation, we evaluate any
150 * When we start in the DFA and reach an accept state that's predicated, we test
175 * decision when looking up a DFA state to see if it already exists. We must
348 // Now we are certain to have a specific decision's DFA, but do we still need an initial state?
351 // The start state for a precedence DFA depends on the current
356 // The start state for a "regular" DFA is just s0.
385 * to convert the computed start state to a precedence start
386 * state. We then use DFA.setPrecedenceStartState to set the
387 * appropriate start state for the precedence level rather
429 * set of ATN configs (proposed DFA state):
431 * does the state uniquely predict an alternative?
432 * does the state have a conflict that would prevent us from
436 * - add an edge from previous DFA state to potentially new DFA state, D,
527 $this->log[] = 'DFA state has preds in DFA sim LL failover';
556 'Ctx sensitive state %s in %s',
614 * Get an existing target state for an edge in the DFA. If the target state
618 * @param DFAState $previousD The current DFA state
621 * @return DFAState|null The existing target DFA state for the given input
622 * symbol `t`, or `null` if the target state for
637 * Compute a target state for an edge in the DFA, and attempt to add
638 * the computed state and corresponding edge to the DFA.
641 * @param DFAState $previousD The current DFA state
644 * @return DFAState|null The computed target DFA state for the given input
646 * state, this method returns
659 // Create new target state; we'll add to DFA after it's complete
690 // in SLL-only mode, we will stop at this state and return the minimum alt
714 // All adds to dfa are done after we've created full D state
725 // Update DFA so reach becomes accept state with (predicate,alt) pairs
903 * Configurations already in a rule stop state indicate reaching the end
921 if ($c->state instanceof RuleStopState) {
941 foreach ($c->state->getTransitions() as $trans) {
960 * trivially indicate a termination state for the overall
970 // Don't pursue the closure if there is just one state.
1005 * a rule stop state.
1020 * closure operation reached such a state. This ensures adaptivePredict
1044 * `configs` are already in a rule stop state, this method simply returns
1049 * state to see if a rule stop state is reachable from the configuration via
1059 * in a rule stop state, otherwise return a new
1061 * from `configs` which are in a rule stop state.
1074 if ($config->state instanceof RuleStopState) {
1080 if ($lookToEndOfRule && $config->state->onlyHasEpsilonTransitions()) {
1081 $nextTokens = $this->atn->nextTokens($config->state);
1084 $endOfRuleState = $this->atn->ruleToStopState[$config->state->ruleIndex];
1114 * predicates evaluated when we reach conflict state (or unique prediction).
1161 * start state. We do this by stripping both predicates and choosing to
1165 * The solution requires a different DFA start state for each precedence level.
1169 * ATN state and predicate context, remove any configuration associated with
1194 * the rule stop state of the LR rule containing state p, corresponding
1199 * This method transforms the start state computed by
1200 * {@see ParserATNSimulator::computeStartState()} to the special start state
1202 * process applies the following changes to the start state's configuration
1209 * same ATN state with the same prediction context. This transformation is
1217 * in a state that is also reachable via alternative 1 is by nesting calls
1229 * If the above grammar, the ATN state immediately before the token
1239 * as the start state for the DFA.
1241 * @return ATNConfigSet The transformed configuration set representing the start state
1267 $statesFromAlt1[$config->state->stateNumber] = $config->context;
1289 $context = $statesFromAlt1[$config->state->stateNumber] ?? null;
1397 * {@see ParserATNSimulator::error()} state was reached during ATN simulation.
1426 * state was reached.
1474 || ($c->state instanceof RuleStopState && $c->context !== null && $c->context->hasEmptyPath())) {
1585 * closure operations if we reach a DFA state that uniquely predicts
1586 * alternative. We will not be caching that DFA state and it is a
1632 if ($config->state instanceof RuleStopState) {
1640 new ATNConfig($config, $config->state, PredictionContext::empty(), null, null),
1648 $this->getRuleName($config->state->ruleIndex)
1667 $newContext = $config->context->getParent($i);// "pop" return state
1700 $this->log[] = \sprintf('FALLING off rule %s.', $this->getRuleName($config->state->ruleIndex));
1720 $p = $config->state;
1741 if ($config->state instanceof RuleStopState) {
1810 * StarLoopEntryState after popping context at the rule end state
1814 * We need to detect any state that can reach loop entry on
1821 * Then we check that each stack top of context is a return state
1824 * 1. 'not' expr, '(' type ')' expr. The return state points at loop entry state
1825 * 2. expr op expr. The return state is the block end of internal block of (...)*
1826 * 3. 'between' expr 'and' expr. The return state of 2nd expr reference.
1827 * That state points at block end of internal block of (...)*.
1828 * 4. expr '?' expr ':' expr. The return state points at block end,
1829 * which points at loop entry state.
1839 * c. lies within expr but at a state not the BlockEndState
1845 * evaluated when computing a DFA start state. I.e., only before
1855 * decision point, decision d=2, compute-start-state performs
1858 * StarLoopEntryState during compute-start-state.
1895 $p = $config->state;
1901 * Are we the special loop entry/exit state? or SLL wildcard
1941 // state through epsilon edges and w/o leaving rule.
1960 // Look for 'expr op expr' or case where expr's return state is block end
1967 // Look for ternary expr ? expr : expr. The return state points at block end,
1968 // which points at loop entry state
1974 // return state points at block end state of (...)* internal block
2220 ambiguous states. If we have another state associated with conflicting
2225 When the ATN simulation reaches the state before ';', it has a DFA
2226 state that looks like: [12|1|[], 6|2|[], 12|2|[]]. Naturally
2229 The key is that we have a single state that has config's only associated
2230 with a single alternative, 2, and crucially the state transitions
2235 associated with a single alt state in the state→config-list map.
2243 After matching input A, we reach the stop state for rule A, state 1.
2244 State 8 is the state right before B. Clearly alternatives 1 and 2
2247 stop working on this state. In the previous example, we're concerned
2250 looking for input reasonably, I don't declare the state done. We
2321 * {@see ParserATNSimulator::addDFAState()} to ensure the `to` state is
2328 * {@see ParserATNSimulator::addDFAState()} for the `to` state.
2331 * @param DFAState|null $from The source state for the edge
2333 * @param DFAState|null $to The target state for the edge
2369 * Add state `D` to the DFA if it is not already present, and return
2370 * the actual instance stored in the DFA. If a state equivalent to `D`
2371 * is already in the DFA, the existing state is returned. Otherwise this
2378 * @param DFAState $D The DFA state to add
2380 * @return DFAState The state stored in the DFA. This will be either
2381 * the existing state if `D` is already in the DFA, or `D`
2382 * itself if the state was not already present.
2408 $this->log[] = \sprintf('Adding new DFA state: %s', (string) $D);