Lines Matching refs:this

87      * implemented as a parser listener so this field is not directly used by
123 $this->errorHandler = new DefaultErrorStrategy();
125 $this->setInputStream($input);
131 if ($this->input !== null) {
132 $this->input->seek(0);
135 $this->errorHandler->reset($this);
136 $this->ctx = null;
137 $this->syntaxErrors = 0;
138 $this->matchedEOF = false;
139 $this->setTrace(false);
140 $this->precedenceStack = [0];
142 $interpreter = $this->getInterpreter();
173 $t = $this->getCurrentToken();
177 $this->matchedEOF = true;
180 $this->errorHandler->reportMatch($this);
182 $this->consume();
184 $t = $this->errorHandler->recoverInline($this);
186 if ($this->buildParseTree && $t->getTokenIndex() === -1) {
189 $this->context()->addErrorNode($this->createErrorNode($this->context(), $t));
217 $t = $this->token();
220 $this->errorHandler->reportMatch($this);
221 $this->consume();
223 $t = $this->errorHandler->recoverInline($this);
225 if ($this->buildParseTree && $t->getTokenIndex() === -1) {
228 $this->context()->addErrorNode($this->createErrorNode($this->context(), $t));
252 $this->buildParseTree = $buildParseTree;
264 return $this->buildParseTree;
272 return $this->parseListeners;
302 if (!\in_array($listener, $this->parseListeners, true)) {
303 $this->parseListeners[] = $listener;
311 * listener, this method does nothing.
319 $index = \array_search($listener, $this->parseListeners, true);
322 unset($this->parseListeners[$index]);
333 $this->parseListeners = [];
343 foreach ($this->parseListeners as $listener) {
344 $listener->enterEveryRule($this->context());
345 $this->context()->enterRule($listener);
356 for ($i = \count($this->parseListeners) - 1; $i >= 0; $i--) {
358 $listener = $this->parseListeners[$i];
359 $this->context()->exitRule($listener);
360 $listener->exitEveryRule($this->context());
372 return $this->syntaxErrors;
377 return $this->tokenStream()->getTokenSource()->getTokenFactory();
385 $this->tokenStream()->getTokenSource()->setTokenFactory($factory);
397 $serializedAtn = $this->getSerializedATN();
412 return $this->errorHandler;
417 $this->errorHandler = $handler;
425 return $this->getTokenStream();
434 $this->setTokenStream($input);
439 return $this->input;
444 if ($this->input === null) {
448 return $this->input;
454 $this->input = null;
455 $this->reset();
456 $this->input = $input;
465 return $this->tokenStream()->LT(1);
470 $token = $this->getCurrentToken();
485 $offendingToken = $this->token();
488 $this->syntaxErrors++;
491 $listener = $this->getErrorListenerDispatch();
492 $listener->syntaxError($this, $offendingToken, $line, $charPositionInLine, $msg, $e);
499 * lookahead symbol, this function moves the cursor to `B` and returns
518 $o = $this->token();
521 $this->tokenStream()->consume();
524 if ($this->buildParseTree || \count($this->parseListeners) > 0) {
525 if ($this->errorHandler->inErrorRecoveryMode($this)) {
526 $node = $this->context()->addErrorNode($this->createErrorNode($this->context(), $o));
528 foreach ($this->parseListeners as $listener) {
534 $node = $this->context()->addTerminalNode($this->createTerminalNode($this->context(), $o));
536 foreach ($this->parseListeners as $listener) {
569 $parent = $this->context()->getParent();
577 $parent->addChild($this->context());
587 $this->setState($state);
588 $this->ctx = $localctx;
589 $this->context()->start = $this->tokenStream()->LT(1);
591 if ($this->buildParseTree) {
592 $this->addContextToParseTree();
595 $this->triggerEnterRuleEvent();
600 if ($this->matchedEOF) {
602 $this->context()->stop = $this->tokenStream()->LT(1); // LT(1) will be end of file
604 $this->context()->stop = $this->tokenStream()->LT(-1); // stop node is what we just matched
608 $this->triggerExitRuleEvent();
610 $this->setState($this->context()->invokingState);
612 $parent = $this->context()->getParent();
615 $this->ctx = $parent;
625 if ($this->buildParseTree && $this->ctx !== $localctx) {
627 $parent = $this->context()->getParent();
635 $this->ctx = $localctx;
646 return $this->precedenceStack[\count($this->precedenceStack) - 1] ?? -1;
651 $this->setState($state);
652 $this->precedenceStack[] = $precedence;
653 $this->ctx = $localctx;
654 $this->context()->start = $this->tokenStream()->LT(1);
656 $this->triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules
666 $previous = $this->context();
669 $previous->stop = $this->tokenStream()->LT(-1);
671 $this->ctx = $localctx;
672 $this->context()->start = $previous->start;
674 if ($this->buildParseTree) {
675 $this->context()->addChild($previous);
678 $this->triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules
683 \array_pop($this->precedenceStack);
685 $this->context()->stop = $this->tokenStream()->LT(-1);
686 $retctx = $this->context(); // save current ctx (return value)
690 if (\count($this->parseListeners) > 0) {
691 while ($this->ctx !== $parentctx) {
692 $this->triggerExitRuleEvent();
693 $parent = $this->context()->getParent();
699 $this->ctx = $parent;
702 $this->ctx = $parentctx;
708 if ($this->buildParseTree && $parentctx !== null) {
716 $p = $this->ctx;
730 return $this->ctx;
735 if ($this->ctx === null) {
739 return $this->ctx;
744 return $this->getRuleNames()[$this->context()->getRuleIndex()] ?? '';
749 $this->ctx = $ctx;
754 return $precedence >= $this->getPrecedence();
765 * ATN. The behavior of this method is equivalent to the following, but is
780 $atn = $this->interpreter()->atn;
782 $ctx = $this->ctx;
783 $s = $atn->states[$this->getState()];
814 return $this->matchedEOF;
826 return $this->getATN()
827 ->getExpectedTokens($this->getState(), $this->getContext());
832 $atn = $this->interpreter()->atn;
833 $s = $atn->states[$this->getState()];
841 return $this->getRuleIndexMap()[$ruleName] ?? -1;
856 $p = $p ?? $this->ctx;
857 $ruleNames = $this->getRuleNames();
884 $interp = $this->getInterpreter();
889 $s[] = $dfa->toString($this->getVocabulary());
899 $interp = $this->getInterpreter();
912 echo \sprintf("Decision %d:\n%s", $dfa->decision, $dfa->toString($this->getVocabulary()));
920 return $this->tokenStream()->getSourceName();
929 if ($this->tracer !== null) {
930 $this->removeParseListener($this->tracer);
934 $this->tracer = new ParserTraceListener($this);
935 $this->addParseListener($this->tracer);
947 return $this->tracer !== null;