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 likeBailErrorStrategyas 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 intfirstErrorTokenIndex-
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 voidrecover(Parser recognizer, RecognitionException e)TokenrecoverInline(Parser recognizer)voidsync(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:
recoverin interfaceANTLRErrorStrategy- Overrides:
recoverin classDefaultErrorStrategy
-
recoverInline
public Token recoverInline(Parser recognizer) throws RecognitionException
- Specified by:
recoverInlinein interfaceANTLRErrorStrategy- Overrides:
recoverInlinein classDefaultErrorStrategy- Throws:
RecognitionException
-
sync
public void sync(Parser recognizer)
- Specified by:
syncin interfaceANTLRErrorStrategy- Overrides:
syncin classDefaultErrorStrategy
-
-