Top Description Fields Constructors Methods
org.apache.groovy.parser.antlr4.internal

public Class DescriptiveErrorStrategy

extends BailErrorStrategy
Class Inheritance
Imports
org.antlr.v4.runtime.BailErrorStrategy, .CharStream, .FailedPredicateException, .InputMismatchException, .NoViableAltException, .Parser, .ParserRuleContext, .RecognitionException, .Token, .TokenStream, org.antlr.v4.runtime.atn.PredictionMode, org.antlr.v4.runtime.misc.Interval, .ParseCancellationException

Provide friendly error messages when parsing errors occurred.

Field Summary

Modifier and TypeField and Description
private CharStream

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
protected String
protected String
public void
recover(Parser
the parser instance
recognizer
,
RecognitionException
the recognition exception to recover from
e
)

Overrides org.antlr.v4.runtime.BailErrorStrategy.recover.

Implements org.antlr.v4.runtime.ANTLRErrorStrategy.recover.

Instead of recovering from exception e, re-throw it wrapped in a ParseCancellationException so it is not caught by the rule function catches.
public Token
recoverInline(Parser
the parser instance
recognizer
)

Overrides org.antlr.v4.runtime.BailErrorStrategy.recoverInline.

Implements org.antlr.v4.runtime.ANTLRErrorStrategy.recoverInline.

Make sure we don't attempt to recover inline; if the parser successfully recovers, it won't throw an exception.
protected void
reportFailedPredicate(Parser
the parser instance
recognizer
,
FailedPredicateException
the recognition exception
e
)

Overrides org.antlr.v4.runtime.DefaultErrorStrategy.reportFailedPredicate.

This is called by reportError when the exception is a FailedPredicateException.
protected void
reportInputMismatch(Parser
the parser instance
recognizer
,
InputMismatchException
the recognition exception
e
)

Overrides org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch.

This is called by reportError when the exception is an InputMismatchException.
protected void
reportNoViableAlternative(Parser
the parser instance
recognizer
,
NoViableAltException
the recognition exception
e
)

Overrides org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative.

This is called by reportError when the exception is a NoViableAltException.
Inherited from org.antlr.v4.runtime.BailErrorStrategy:
sync

Field Detail

charStreamback to summary
private CharStream charStream

Constructor Detail

DescriptiveErrorStrategyback to summary
public DescriptiveErrorStrategy(CharStream charStream)

Method Detail

createFailedPredicateErrorMessageback to summary
protected String createFailedPredicateErrorMessage(Parser recognizer, FailedPredicateException e)
createInputMismatchErrorMessageback to summary
protected String createInputMismatchErrorMessage(Parser recognizer, InputMismatchException e)
createNoViableAlternativeErrorMessageback to summary
protected String createNoViableAlternativeErrorMessage(Parser recognizer, NoViableAltException e)
recoverback to summary
public void recover(Parser recognizer, RecognitionException e)

Overrides org.antlr.v4.runtime.BailErrorStrategy.recover.

Implements org.antlr.v4.runtime.ANTLRErrorStrategy.recover.

Doc from org.antlr.v4.runtime.BailErrorStrategy.recover.

Instead of recovering from exception e, re-throw it wrapped in a ParseCancellationException so it is not caught by the rule function catches. Use Exception#getCause() to get the original RecognitionException.

Parameters
recognizer:Parser

Doc from org.antlr.v4.runtime.ANTLRErrorStrategy.recover.

the parser instance

e:RecognitionException

Doc from org.antlr.v4.runtime.ANTLRErrorStrategy.recover.

the recognition exception to recover from

Annotations
@Override
recoverInlineback to summary
public Token recoverInline(Parser recognizer) throws RecognitionException

Overrides org.antlr.v4.runtime.BailErrorStrategy.recoverInline.

Implements org.antlr.v4.runtime.ANTLRErrorStrategy.recoverInline.

Doc from org.antlr.v4.runtime.BailErrorStrategy.recoverInline.

Make sure we don't attempt to recover inline; if the parser successfully recovers, it won't throw an exception.

Parameters
recognizer:Parser

Doc from org.antlr.v4.runtime.ANTLRErrorStrategy.recoverInline.

the parser instance

Annotations
@Override
Exceptions
RecognitionException:

Doc from org.antlr.v4.runtime.ANTLRErrorStrategy.recoverInline.

if the error strategy was not able to recover from the unexpected input symbol

reportFailedPredicateback to summary
protected void reportFailedPredicate(Parser recognizer, FailedPredicateException e)

Overrides org.antlr.v4.runtime.DefaultErrorStrategy.reportFailedPredicate.

Doc from org.antlr.v4.runtime.DefaultErrorStrategy.reportFailedPredicate.

This is called by reportError when the exception is a FailedPredicateException.

Parameters
recognizer:Parser

the parser instance

e:FailedPredicateException

the recognition exception

reportInputMismatchback to summary
protected void reportInputMismatch(Parser recognizer, InputMismatchException e)

Overrides org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch.

Doc from org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch.

This is called by reportError when the exception is an InputMismatchException.

Parameters
recognizer:Parser

the parser instance

e:InputMismatchException

the recognition exception

reportNoViableAlternativeback to summary
protected void reportNoViableAlternative(Parser recognizer, NoViableAltException e)

Overrides org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative.

Doc from org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative.

This is called by reportError when the exception is a NoViableAltException.

Parameters
recognizer:Parser

the parser instance

e:NoViableAltException

the recognition exception

Annotations
@Override