UNPKG

3.42 kBTypeScriptView Raw
1/*!
2 * Copyright 2016 The ANTLR Project. All rights reserved.
3 * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
4 */
5import { ATNConfigSet } from "./atn/ATNConfigSet";
6import { BitSet } from "./misc/BitSet";
7import { DFA } from "./dfa/DFA";
8import { Parser } from "./Parser";
9import { ParserErrorListener } from "./ParserErrorListener";
10import { RecognitionException } from "./RecognitionException";
11import { Recognizer } from "./Recognizer";
12import { SimulatorState } from "./atn/SimulatorState";
13import { Token } from "./Token";
14/**
15 * This implementation of {@link ANTLRErrorListener} can be used to identify
16 * certain potential correctness and performance problems in grammars. "Reports"
17 * are made by calling {@link Parser#notifyErrorListeners} with the appropriate
18 * message.
19 *
20 * * **Ambiguities**: These are cases where more than one path through the
21 * grammar can match the input.
22 * * **Weak context sensitivity**: These are cases where full-context
23 * prediction resolved an SLL conflict to a unique alternative which equaled the
24 * minimum alternative of the SLL conflict.
25 * * **Strong (forced) context sensitivity**: These are cases where the
26 * full-context prediction resolved an SLL conflict to a unique alternative,
27 * *and* the minimum alternative of the SLL conflict was found to not be
28 * a truly viable alternative. Two-stage parsing cannot be used for inputs where
29 * this situation occurs.
30 *
31 * @author Sam Harwell
32 */
33export declare class DiagnosticErrorListener implements ParserErrorListener {
34 protected exactOnly: boolean;
35 /**
36 * Initializes a new instance of {@link DiagnosticErrorListener}, specifying
37 * whether all ambiguities or only exact ambiguities are reported.
38 *
39 * @param exactOnly `true` to report only exact ambiguities, otherwise
40 * `false` to report all ambiguities. Defaults to true.
41 */
42 constructor(exactOnly?: boolean);
43 syntaxError<T extends Token>(recognizer: Recognizer<T, any>, offendingSymbol: T | undefined, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): void;
44 reportAmbiguity(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, exact: boolean, ambigAlts: BitSet | undefined, configs: ATNConfigSet): void;
45 reportAttemptingFullContext(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, conflictingAlts: BitSet | undefined, conflictState: SimulatorState): void;
46 reportContextSensitivity(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, prediction: number, acceptState: SimulatorState): void;
47 protected getDecisionDescription(recognizer: Parser, dfa: DFA): string;
48 /**
49 * Computes the set of conflicting or ambiguous alternatives from a
50 * configuration set, if that information was not already provided by the
51 * parser.
52 *
53 * @param reportedAlts The set of conflicting or ambiguous alternatives, as
54 * reported by the parser.
55 * @param configs The conflicting or ambiguous configuration set.
56 * @returns Returns `reportedAlts` if it is not `undefined`, otherwise
57 * returns the set of alternatives represented in `configs`.
58 */
59 protected getConflictingAlts(reportedAlts: BitSet | undefined, configs: ATNConfigSet): BitSet;
60}