Lines Matching defs:DFA

20 use Antlr\Antlr4\Runtime\Dfa\DFA;
44 * We begin with ATN simulation to build paths in a DFA. Subsequent prediction
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
51 * a DFA that is not dependent upon the rule invocation stack when we do a
52 * prediction. One DFA works in all contexts. We avoid using context not
53 * necessarily because it's slower, although it can be, but because of the DFA
63 * to the DFA. Configuration context stacks will be the full invocation stacks
70 * The next time we reach this DFA state with an SLL conflict, through DFA
97 * X to a specific DFA for that context.
139 * closure, the DFA state configuration sets would be different and we couldn't
140 * build up a suitable DFA.
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
159 * SHARING DFA
165 * {@see PredictionContext} objects are shared among the DFA states. This makes
171 * field when it adds a new DFA object to that array.
172 * {@see ParserATNSimulator::$addDFAEdge} locks on the DFA for the current
174 * {@see ParserATNSimulator::addDFAState()} locks on the DFA for the current
175 * decision when looking up a DFA state to see if it already exists. We must
176 * make sure that all requests to add DFA states that are equivalent result in
177 * the same shared DFA object. This is because lots of threads will be trying
178 * to update the DFA at once. {@see ParserATNSimulator::addDFAState()} also
179 * locks inside the DFA lock but this time on the shared context cache when it
181 * subgraphs/nodes. No other locking occurs, even during DFA simulation. This is
184 * into the DFA, the DFA simulation does not reference the {@see DFA::$states} map.
185 * It follows the {@see DFAState::$edges} field to new targets. The DFA simulator
189 * but in either case the DFA simulator works; if `null`, and requests ATN
259 /** @var array<DFA> */
291 /** @var DFA|null */
295 * @param array<DFA> $decisionToDFA
319 $this->decisionToDFA[$d] = new DFA($decisionState, $d);
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
352 // parser precedence, and is provided by a DFA method.
356 // The start state for a "regular" DFA is just s0.
384 * If this is a precedence DFA, we use applyPrecedenceFilter
386 * state. We then use DFA.setPrecedenceStartState to set the
388 * than simply setting DFA.s0.
392 throw new \RuntimeException('DFA.s0 cannot be null.');
411 $this->log[] = \sprintf('DFA after predictATN: %s', $dfa->toString($this->parser->getVocabulary()));
425 * upon the remaining input, but also updates the DFA cache to avoid
429 * set of ATN configs (proposed DFA state):
436 * - add an edge from previous DFA state to potentially new DFA state, D,
439 * - collecting predicates and adding semantic context to DFA accept states
440 * - adding rule context to context-sensitive DFA accept states
455 DFA $dfa,
489 throw new \RuntimeException('DFA State cannot be null.');
527 $this->log[] = 'DFA state has preds in DFA sim LL failover';
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
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.
640 * @param DFA $dfa The DFA
641 * @param DFAState $previousD The current DFA state
644 * @return DFAState|null The computed target DFA state for the given input
645 * symbol `t`. If `t` does not lead to a valid DFA
649 public function computeTargetState(DFA $dfa, DFAState $previousD, int $t) : ?DFAState
659 // Create new target state; we'll add to DFA after it's complete
722 // We need to test all predicates, even in DFA states that uniquely predict alternative.
725 // Update DFA so reach becomes accept state with (predicate,alt) pairs
753 DFA $dfa,
1165 * The solution requires a different DFA start state for each precedence level.
1201 * used by a precedence DFA for a particular precedence value. The transformation
1239 * as the start state for the DFA.
1242 * for a precedence DFA at a particular precedence level
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
1845 * evaluated when computing a DFA start state. I.e., only before
2225 When the ATN simulation reaches the state before ';', it has a DFA
2320 * Add an edge to the DFA, if possible. This method calls
2322 * present in the DFA. If `from` is `null`, or if `t` is outside the
2323 * range of edges that can be represented in the DFA tables, this method
2324 * returns without adding the edge to the DFA.
2330 * @param DFA $dfa The DFA
2339 protected function addDFAEdge(DFA $dfa, ?DFAState $from, int $t, ?DFAState $to) : ?DFAState
2362 $this->log[] = 'DFA =' . \PHP_EOL . $dfa->toString($this->parser->getVocabulary());
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
2372 * method returns `D` after adding it to the DFA.
2375 * {@see ParserATNSimulator::error()} and does not change the DFA.
2377 * @param DFA $dfa The dfa
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`
2386 protected function addDFAState(DFA $dfa, DFAState $D) : DFAState
2408 $this->log[] = \sprintf('Adding new DFA state: %s', (string) $D);
2415 DFA $dfa,
2446 DFA $dfa,
2480 DFA $dfa,