public class DefaultErrorStrategy extends Object implements ANTLRErrorStrategy
| Modifier and Type | Field and Description |
|---|---|
protected TokenFactory<?> |
_factory
How to create token objects
|
protected boolean |
errorRecoveryMode
This is true after we see an error and before having successfully
matched a token.
|
protected int |
lastErrorIndex
The index into the input stream where the last error occurred.
|
protected IntervalSet |
lastErrorStates |
| Constructor and Description |
|---|
DefaultErrorStrategy() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginErrorCondition(Parser recognizer)
Notify handler that parser has entered an error state.
|
void |
consumeUntil(Parser recognizer,
IntervalSet set)
Consume tokens until one matches the given token set
|
void |
endErrorCondition(Parser recognizer)
Reset the error handler.
|
protected String |
escapeWSAndQuote(String s) |
protected IntervalSet |
getErrorRecoverySet(Parser recognizer) |
IntervalSet |
getExpectedTokens(Parser recognizer) |
protected Token |
getMissingSymbol(Parser recognizer)
Conjure up a missing token during error recovery.
|
protected String |
getSymbolText(Token symbol) |
protected int |
getSymbolType(Token symbol) |
String |
getTokenErrorDisplay(Token t)
How should a token be displayed in an error message? The default
is to display just the text, but during development you might
want to have a lot of information spit out.
|
boolean |
inErrorRecoveryMode(Parser recognizer)
Is the parser in the process of recovering from an error? Upon
a syntax error, the parser enters recovery mode and stays there until
the next successful match of a token.
|
void |
recover(Parser recognizer,
RecognitionException e)
Recover from NoViableAlt errors.
|
Token |
recoverInline(Parser recognizer)
Attempt to recover from a single missing or extra token.
|
void |
reportError(Parser recognizer,
RecognitionException e)
Report any kind of RecognitionException.
|
void |
reportFailedPredicate(Parser recognizer,
FailedPredicateException e) |
void |
reportInputMismatch(Parser recognizer,
InputMismatchException e) |
void |
reportMissingToken(Parser recognizer) |
void |
reportNoViableAlternative(Parser recognizer,
NoViableAltException e) |
void |
reportUnwantedToken(Parser recognizer) |
void |
setTokenFactory(TokenFactory<?> factory)
To create missing tokens, we need a factory
|
Token |
singleTokenDeletion(Parser recognizer) |
boolean |
singleTokenInsertion(Parser recognizer) |
void |
sync(Parser recognizer)
Make sure that the current lookahead symbol is consistent with
what were expecting at this point in the ATN.
|
protected TokenFactory<?> _factory
protected boolean errorRecoveryMode
protected int lastErrorIndex
protected IntervalSet lastErrorStates
public void setTokenFactory(TokenFactory<?> factory)
ANTLRErrorStrategysetTokenFactory in interface ANTLRErrorStrategypublic void beginErrorCondition(Parser recognizer)
ANTLRErrorStrategybeginErrorCondition in interface ANTLRErrorStrategypublic boolean inErrorRecoveryMode(Parser recognizer)
ANTLRErrorStrategyinErrorRecoveryMode in interface ANTLRErrorStrategypublic void endErrorCondition(Parser recognizer)
ANTLRErrorStrategyendErrorCondition in interface ANTLRErrorStrategypublic void reportError(Parser recognizer, RecognitionException e) throws RecognitionException
ANTLRErrorStrategyreportError in interface ANTLRErrorStrategyRecognitionExceptionpublic void recover(Parser recognizer, RecognitionException e)
recover in interface ANTLRErrorStrategypublic void sync(Parser recognizer)
sync in interface ANTLRErrorStrategypublic void reportNoViableAlternative(Parser recognizer, NoViableAltException e) throws RecognitionException
RecognitionExceptionpublic void reportInputMismatch(Parser recognizer, InputMismatchException e) throws RecognitionException
RecognitionExceptionpublic void reportFailedPredicate(Parser recognizer, FailedPredicateException e) throws RecognitionException
RecognitionExceptionpublic void reportUnwantedToken(Parser recognizer)
public void reportMissingToken(Parser recognizer)
public Token recoverInline(Parser recognizer) throws RecognitionException
recoverInline in interface ANTLRErrorStrategyRecognitionExceptionpublic boolean singleTokenInsertion(Parser recognizer)
protected Token getMissingSymbol(Parser recognizer)
public IntervalSet getExpectedTokens(Parser recognizer)
public String getTokenErrorDisplay(Token t)
protected IntervalSet getErrorRecoverySet(Parser recognizer)
public void consumeUntil(Parser recognizer, IntervalSet set)
Copyright © 1992-2013 ANTLR. All Rights Reserved.