reportNoViableAlternative method

void reportNoViableAlternative(
  1. Parser recognizer,
  2. NoViableAltException e
)

This is called by {@link #reportError} when the exception is a NoViableAltException.

@see #reportError

@param recognizer the parser instance @param e the recognition exception

Implementation

void reportNoViableAlternative(Parser recognizer, NoViableAltException e) {
  final tokens = recognizer.inputStream;
  String input;

  if (e.startToken.type == Token.EOF) {
    input = '<EOF>';
  } else {
    input = tokens.getTextRange(e.startToken, e.offendingToken);
  }

  final msg = 'no viable alternative at input ' + escapeWSAndQuote(input);
  recognizer.notifyErrorListeners(msg, e.offendingToken, e);
}