reportMissingToken method
This method is called to report a syntax error which requires the
insertion of a missing token into the input stream. At the time this
method is called, the missing token has not yet been inserted. When this
method returns, recognizer
is in error recovery mode.
This method is called when {@link #singleTokenInsertion} identifies single-token insertion as a viable recovery strategy for a mismatched input error.
The default implementation simply returns if the handler is already in error recovery mode. Otherwise, it calls {@link #beginErrorCondition} to enter error recovery mode, followed by calling {@link Parser#notifyErrorListeners}.
@param recognizer the parser instance
Implementation
void reportMissingToken(Parser recognizer) {
if (inErrorRecoveryMode(recognizer)) {
return;
}
beginErrorCondition(recognizer);
final t = recognizer.currentToken;
final expecting = getExpectedTokens(recognizer);
final msg = 'missing ' +
expecting.toString(vocabulary: recognizer.vocabulary) +
' at ' +
getTokenErrorDisplay(t);
recognizer.notifyErrorListeners(msg, t, null);
}