public class DescriptiveErrorStrategy
extends AbstractFriendlyErrorStrategy
Fail-fast parser error strategy with friendly diagnostics (default Parrot mode).
Cancels the parse with ParseCancellationException after reporting,
matching BailErrorStrategy. sync is a
no-op so the SLL stage of two-stage parsing stays cheap. Diagnostics are
emitted from recover: after a failed SLL probe the strategy may still
be in ANTLR's internal recovery mode, which suppresses
reportError, while recover still runs under LL.
For IDE multi-error collection use create(CharStream, boolean) with
recover == true, which selects
RecoveringDescriptiveErrorStrategy. Hosts should treat
ErrorCollector as the multi-error source
of truth: recovery may still produce a partial tree that fails later during
AST building.
| Constructor and description |
|---|
DescriptiveErrorStrategy(CharStream charStream)Fail-fast strategy with friendly diagnostics. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static ANTLRErrorStrategy |
create(CharStream charStream, boolean recover)Select fail-fast or recovering strategy. |
|
public void |
recover(Parser recognizer, RecognitionException e) |
|
public Token |
recoverInline(Parser recognizer) |
|
public void |
sync(Parser recognizer) |
| Methods inherited from class | Name |
|---|---|
class AbstractFriendlyErrorStrategy |
createFailedPredicateErrorMessage, createInputMismatchErrorMessage, createNoViableAlternativeErrorMessage, reportFailedPredicate, reportInputMismatch, reportNoViableAlternative |
Fail-fast strategy with friendly diagnostics.
charStream - source character stream used for snippet extractionSelect fail-fast or recovering strategy.
charStream - source character stream used for snippet extractionrecover - true for multi-error resync; false for fail-fastnull)
Mark incomplete contexts, emit a friendly LL diagnostic, then cancel.
Bail-style: never return a synthetic token; report then cancel.
No-op (matches BailErrorStrategy) so SLL stays cheap.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.