Javadoc
Attempt to recover from a syntax error. This returns false if recovery
fails, true if it succeeds. Recovery happens in 4 steps. First we
pop the parse stack down to a point at which we have a shift out
of the top-most state on the error Symbol. This represents the
initial error recovery configuration. If no such configuration is
found, then we fail. Next a small number of "lookahead" or "parse
ahead" Symbols are read into a buffer. The size of this buffer is
determined by error_sync_size() and determines how many Symbols beyond
the error must be matched to consider the recovery a success. Next,
we begin to discard Symbols in attempt to get past the point of error
to a point where we can continue parsing. After each Symbol, we attempt
to "parse ahead" though the buffered lookahead Symbols. The "parse ahead"
process simulates that actual parse, but does not modify the real
parser's configuration, nor execute any actions. If we can parse all
the stored Symbols without error, then the recovery is considered a
success. Once a successful recovery point is determined, we do an
actual parse over the stored input -- modifying the real parse
configuration and executing all actions. Finally, we return the the
normal parser to continue with the overall parse.