Package org.antlr.v4.tool
Class GrammarParserInterpreter.BailButConsumeErrorStrategy
- java.lang.Object
-
- org.antlr.v4.runtime.DefaultErrorStrategy
-
- org.antlr.v4.tool.GrammarParserInterpreter.BailButConsumeErrorStrategy
-
- All Implemented Interfaces:
ANTLRErrorStrategy
- Enclosing class:
- GrammarParserInterpreter
public static class GrammarParserInterpreter.BailButConsumeErrorStrategy extends DefaultErrorStrategy
We want to stop and track the first error but we cannot bail out likeBailErrorStrategy
as consume() constructs trees. We make sure to create an error node during recovery with this strategy. We consume() 1 token during the "bail out of rule" mechanism in recover() and let it fall out of the rule to finish constructing trees. For recovery in line, we throw InputMismatchException to engage recover().
-
-
Field Summary
Fields Modifier and Type Field Description int
firstErrorTokenIndex
-
Fields inherited from class org.antlr.v4.runtime.DefaultErrorStrategy
errorRecoveryMode, lastErrorIndex, lastErrorStates, nextTokensContext, nextTokensState
-
-
Constructor Summary
Constructors Constructor Description BailButConsumeErrorStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
recover(Parser recognizer, RecognitionException e)
Token
recoverInline(Parser recognizer)
void
sync(Parser recognizer)
-
Methods inherited from class org.antlr.v4.runtime.DefaultErrorStrategy
beginErrorCondition, consumeUntil, endErrorCondition, escapeWSAndQuote, getErrorRecoverySet, getExpectedTokens, getMissingSymbol, getSymbolText, getSymbolType, getTokenErrorDisplay, inErrorRecoveryMode, reportError, reportFailedPredicate, reportInputMismatch, reportMatch, reportMissingToken, reportNoViableAlternative, reportUnwantedToken, reset, singleTokenDeletion, singleTokenInsertion
-
-
-
-
Method Detail
-
recover
public void recover(Parser recognizer, RecognitionException e)
- Specified by:
recover
in interfaceANTLRErrorStrategy
- Overrides:
recover
in classDefaultErrorStrategy
-
recoverInline
public Token recoverInline(Parser recognizer) throws RecognitionException
- Specified by:
recoverInline
in interfaceANTLRErrorStrategy
- Overrides:
recoverInline
in classDefaultErrorStrategy
- Throws:
RecognitionException
-
sync
public void sync(Parser recognizer)
- Specified by:
sync
in interfaceANTLRErrorStrategy
- Overrides:
sync
in classDefaultErrorStrategy
-
-