The default implementation simply calls
///
The default implementation simply calls
///
The default implementation returns immediately if the handler is already
/// in error recovery mode. Otherwise, it calls
/// e
/// according to the following table.
The default implementation resynchronizes the parser by consuming tokens /// until we find one in the resynchronization set--loosely the set of tokens /// that can follow the current rule.
///Implements Jim Idle's magic sync mechanism in closures and optional /// subrules. E.g.,
////// a : sync ( stuff sync )* ; /// sync : {consume to what can follow sync} ; ////// At the start of a sub rule upon error, ///
If the sub rule is optional (
/// (...)?
/// ,
/// (...)*
/// , or block
/// with an empty alternative), then the expected set includes what follows
/// the subrule.
During loop iteration, it consumes until it sees a token that can start a /// sub rule or what follows loop. Yes, that is pretty aggressive. We opt to /// stay in the loop as long as possible.
///ORIGINS
///Previous versions of ANTLR did a poor job of their recovery within loops. /// A single mismatch token or missing token would force the parser to bail /// out of the entire rules surrounding the loop. So, for rule
////// classDef : 'class' ID '{' member* '}' ////// input with an extra token between members would force the parser to /// consume until it found the next class definition rather than the next /// member definition of the current class. ///
This functionality cost a little bit of effort because the parser has to /// compare token set at the start of the loop and at each iteration. If for /// some reason speed is suffering for you, you can turn off this /// functionality by simply overriding this method as a blank { }.
///LT(1)
/// symbol and has not yet been
/// removed from the input stream. When this method returns,
/// recognizer
/// is in error recovery mode.
/// This method is called when
///
The default implementation simply returns if the handler is already in
/// error recovery mode. Otherwise, it calls
///
recognizer
/// is in error recovery mode.
/// This method is called when
///
The default implementation simply returns if the handler is already in
/// error recovery mode. Otherwise, it calls
///
The default implementation attempts to recover from the mismatched input
/// by using single token insertion and deletion as described below. If the
/// recovery attempt fails, this method throws an
///
EXTRA TOKEN (single token deletion)
///
/// LA(1)
/// is not what we are looking for. If
/// LA(2)
/// has the
/// right token, however, then assume
/// LA(1)
/// is some extra spurious
/// token and delete it. Then consume and return the next token (which was
/// the
/// LA(2)
/// token) as the successful result of the match operation.
This recovery strategy is implemented by
///
MISSING TOKEN (single token insertion)
///If current token (at
/// LA(1)
/// ) is consistent with what could come
/// after the expected
/// LA(1)
/// token, then assume the token is missing
/// and use the parser's
///
This recovery strategy is implemented by
///
EXAMPLE
///For example, Input
/// i=(3;
/// is clearly missing the
/// ')'
/// . When
/// the parser returns from the nested call to
/// expr
/// , it will have
/// call chain:
/// stat → expr → atom ////// and it will be trying to match the ///
')'
/// at this point in the
/// derivation:
/// /// => ID '=' '(' INT ')' ('+' atom)* ';' /// ^ ////// The attempt to match ///
')'
/// will fail when it sees
/// ';'
/// and
/// call
/// LA(1)==';'
/// is in the set of tokens that can follow the
/// ')'
/// token reference
/// in rule
/// atom
/// . It can assume that you forgot the
/// ')'
/// .
/// true
/// ,
/// recognizer
/// will be in error recovery
/// mode.
/// This method determines whether or not single-token insertion is viable by
/// checking if the
/// LA(1)
/// input symbol could be successfully matched
/// if it were instead the
/// LA(2)
/// symbol. If this method returns
/// true
/// , the caller is responsible for creating and inserting a
/// token with the correct type to produce this behavior.
true
/// if single-token insertion is a viable recovery
/// strategy for the current mismatched input, otherwise
/// false
/// recognizer
/// will not be in error recovery mode since the
/// returned token was a successful match.
/// If the single-token deletion is successful, this method calls
///
null
///