reportContextSensitivity method

  1. @override
void reportContextSensitivity(
  1. Parser recognizer,
  2. DFA dfa,
  3. int startIndex,
  4. int stopIndex,
  5. int prediction,
  6. ATNConfigSet configs,
)
override

This method is called by the parser when a full-context prediction has a unique result.

Each full-context prediction which does not result in a syntax error will call either {@link #reportContextSensitivity} or {@link #reportAmbiguity}.

For prediction implementations that only evaluate full-context predictions when an SLL conflict is found (including the default [ParserATNSimulator] implementation), this method reports cases where SLL conflicts were resolved to unique full-context predictions, i.e. the decision was context-sensitive. This report does not necessarily indicate a problem, and it may appear even in completely unambiguous grammars.

[configs] may have more than one represented alternative if the full-context prediction algorithm does not evaluate predicates before beginning the full-context prediction. In all cases, the final prediction is passed as the [prediction] argument.

Note that the definition of "context sensitivity" in this method differs from the concept in {@link DecisionInfo#contextSensitivities}. This method reports all instances where an SLL conflict occurred but LL parsing produced a unique result, whether or not that unique result matches the minimum alternative in the SLL conflicting set.

This method is not used by lexers.

@param recognizer the parser instance @param dfa the DFA for the current decision @param startIndex the input index where the decision started @param stopIndex the input index where the context sensitivity was finally determined @param prediction the unambiguous result of the full-context prediction @param configs the ATN configuration set where the unambiguous prediction was determined

Implementation

@override
void reportContextSensitivity(
  Parser recognizer,
  DFA dfa,
  int startIndex,
  int stopIndex,
  int prediction,
  ATNConfigSet configs,
) {
  for (final listener in delegates) {
    listener.reportContextSensitivity(
      recognizer,
      dfa,
      startIndex,
      stopIndex,
      prediction,
      configs,
    );
  }
}