Lines Matching +defs:input +defs:s

41      * The current token's starting index into the character stream.
51 * The line number 1..n within the input.
121 public function match(CharStream $input, int $mode) : int
132 $mark = $input->mark();
135 $this->startIndex = $input->getIndex();
141 return $this->matchATN($input);
143 return $this->execATN($input, $dfa->s0);
145 $input->release($mark);
158 protected function matchATN(CharStream $input) : int
163 $this->log[] = \sprintf('matchATN mode %d start: %s', $this->mode, (string) $startState);
168 $s0_closure = $this->computeStartState($input, $startState);
178 $predict = $this->execATN($input, $next);
181 $this->log[] = \sprintf('DFA after matchATN: %s', $this->decisionToDFA[$old_mode]->toLexerString());
187 protected function execATN(CharStream $input, DFAState $ds0) : int
190 $this->log[] = \sprintf('start state closure=%s', (string) $ds0->configs);
195 $this->captureSimState($this->prevAccept, $input, $ds0);
198 $t = $input->LA(1);
199 $s = $ds0; // s is current/from DFA state
203 $this->log[] = \sprintf('execATN loop starting closure: %s', (string) $s->configs);
209 // be able to avoid doing a reach operation upon t. If s!=null,
211 // creating a DFA state. Once we know s!=null, we check to see if
213 // it's configuration set; there's no point in re-computing it.
223 // print("Target for:" + str(s) + " and:" + str(t))
224 $target = $this->getExistingTargetState($s, $t);
227 $target = $this->computeTargetState($input, $s, $t);
234 // If this is a consumable input element, make sure to consume before
235 // capturing the accept state so the input index, line, and char
239 $this->consume($input);
243 $this->captureSimState($this->prevAccept, $input, $target);
249 $t = $input->LA(1);
250 $s = $target; // flip; current DFA target becomes new src/from state
253 return $this->failOrAccept($this->prevAccept, $input, $s->configs, $t);
261 * @param DFAState $s The current DFA state
262 * @param int $t The next input symbol
264 * @return DFAState|null The existing target DFA state for the given input symbol
268 protected function getExistingTargetState(DFAState $s, int $t) : ?DFAState
270 if ($s->edges === null || $t < self::MIN_DFA_EDGE || $t > self::MAX_DFA_EDGE) {
274 $target = $s->edges[$t - self::MIN_DFA_EDGE] ?? null;
277 $this->log[] = \sprintf('reuse state %d edge to %d', $s->stateNumber, $target->stateNumber);
287 * @param CharStream $input The input stream
288 * @param DFAState $s The current DFA state
289 * @param int $t The next input symbol
291 * @return DFAState The computed target DFA state for the given input symbol
295 protected function computeTargetState(CharStream $input, DFAState $s, int $t) : DFAState
301 $this->getReachableConfigSet($input, $s->configs, $reach, $t);
304 // we got nowhere on t from s
308 $this->addDFAEdge($s, $t, ATNSimulator::error());
315 // Add an edge from s to target DFA found/created for reach
316 return $this->addDFAEdgeATNConfigSet($s, $t, $reach) ?? ATNSimulator::error();
319 protected function failOrAccept(SimState $prevAccept, CharStream $input, ATNConfigSet $reach, int $t) : int
331 $input,
343 if ($t === IntStream::EOF && $input->getIndex() === $this->startIndex) {
351 throw new LexerNoViableAltException($this->recog, $input, $this->startIndex, $reach);
356 * we can reach upon input `t`. Parameter `reach` is a return parameter.
359 CharStream $input,
381 "testing %s at %s\n",
394 $lexerExecutor = $lexerExecutor->fixOffsetBeforeMatch($input->getIndex() - $this->startIndex);
401 $input,
418 CharStream $input,
426 $this->log[] = \sprintf('ACTION %s', (string) $lexerActionExecutor) . \PHP_EOL;
430 $input->seek($index);
435 $lexerActionExecutor->execute($this->recog, $input, $startIndex);
448 protected function computeStartState(CharStream $input, ATNState $p) : OrderedATNConfigSet
456 $this->closure($input, $cfg, $configs, false, false, false);
472 CharStream $input,
482 $this->log[] = \sprintf('closure(%s)', $config->toString(true));
489 "closure at %s rule stop %s\n",
494 $this->log[] = \sprintf("closure at rule stop %s\n", $config);
516 $input,
538 $cfg = $this->getEpsilonTarget($input, $config, $trans, $configs, $speculative, $treatEofAsEpsilon);
542 $input,
559 CharStream $input,
589 // semantically it's not used that often. One of the key elements to
611 if ($this->evaluatePredicate($input, $t->ruleIndex, $t->predIndex, $speculative)) {
680 * lexer state. This method should restore `input` and the simulator
684 * @param CharStream $input The input stream.
687 * @param bool $speculative `true` if the current index in `input` is
688 * one character before the predicate's location.
692 protected function evaluatePredicate(CharStream $input, int $ruleIndex, int $predIndex, bool $speculative) : bool
704 $index = $input->getIndex();
705 $marker = $input->mark();
708 $this->consume($input);
714 $input->seek($index);
715 $input->release($marker);
719 protected function captureSimState(SimState $settings, CharStream $input, DFAState $dfaState) : void
721 $settings->setIndex($input->getIndex());
731 * dependent on the specific input sequence, so the static edge in the
763 $this->log[] = \sprintf('EDGE %s->%s upon %d', $from, $to, $t);
836 public function getText(CharStream $input) : string
839 return $input->getText($this->startIndex, $input->getIndex() - 1);
842 public function consume(CharStream $input) : void
844 $curChar = $input->LA(1);
853 $input->consume();
862 return \sprintf('\'%s\'', StringUtils::char($t));