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 | */
|
5 | import { CharStream } from "./CharStream";
|
6 | import { IntervalSet } from "./misc/IntervalSet";
|
7 | import { IntStream } from "./IntStream";
|
8 | import { Lexer } from "./Lexer";
|
9 | import { ParserRuleContext } from "./ParserRuleContext";
|
10 | import { Recognizer } from "./Recognizer";
|
11 | import { RuleContext } from "./RuleContext";
|
12 | import { Token } from "./Token";
|
13 | /** The root of the ANTLR exception hierarchy. In general, ANTLR tracks just
|
14 | * 3 kinds of errors: prediction errors, failed predicate errors, and
|
15 | * mismatched input errors. In each case, the parser knows where it is
|
16 | * in the input, where it is in the ATN, the rule invocation stack,
|
17 | * and what kind of problem occurred.
|
18 | */
|
19 | export declare class RecognitionException extends Error {
|
20 | /** The {@link Recognizer} where this exception originated. */
|
21 | private _recognizer?;
|
22 | private ctx?;
|
23 | private input?;
|
24 | /**
|
25 | * The current {@link Token} when an error occurred. Since not all streams
|
26 | * support accessing symbols by index, we have to track the {@link Token}
|
27 | * instance itself.
|
28 | */
|
29 | private offendingToken?;
|
30 | private _offendingState;
|
31 | constructor(lexer: Lexer | undefined, input: CharStream);
|
32 | constructor(recognizer: Recognizer<Token, any> | undefined, input: IntStream | undefined, ctx: ParserRuleContext | undefined);
|
33 | constructor(recognizer: Recognizer<Token, any> | undefined, input: IntStream | undefined, ctx: ParserRuleContext | undefined, message: string);
|
34 | /**
|
35 | * Get the ATN state number the parser was in at the time the error
|
36 | * occurred. For {@link NoViableAltException} and
|
37 | * {@link LexerNoViableAltException} exceptions, this is the
|
38 | * {number. For others, it is the state whose outgoing
DecisionState} |
39 | * edge we couldn't match.
|
40 | *
|
41 | * If the state number is not known, this method returns -1.
|
42 | */
|
43 | get offendingState(): number;
|
44 | protected setOffendingState(offendingState: number): void;
|
45 | /**
|
46 | * Gets the set of input symbols which could potentially follow the
|
47 | * previously matched symbol at the time this exception was thrown.
|
48 | *
|
49 | * If the set of expected tokens is not known and could not be computed,
|
50 | * this method returns `undefined`.
|
51 | *
|
52 | * @returns The set of token types that could potentially follow the current
|
53 | * state in the ATN, or `undefined` if the information is not available.
|
54 | */
|
55 | get expectedTokens(): IntervalSet | undefined;
|
56 | /**
|
57 | * Gets the {@link RuleContext} at the time this exception was thrown.
|
58 | *
|
59 | * If the context is not available, this method returns `undefined`.
|
60 | *
|
61 | * @returns The {@link RuleContext} at the time this exception was thrown.
|
62 | * If the context is not available, this method returns `undefined`.
|
63 | */
|
64 | get context(): RuleContext | undefined;
|
65 | /**
|
66 | * Gets the input stream which is the symbol source for the recognizer where
|
67 | * this exception was thrown.
|
68 | *
|
69 | * If the input stream is not available, this method returns `undefined`.
|
70 | *
|
71 | * @returns The input stream which is the symbol source for the recognizer
|
72 | * where this exception was thrown, or `undefined` if the stream is not
|
73 | * available.
|
74 | */
|
75 | get inputStream(): IntStream | undefined;
|
76 | getOffendingToken(recognizer?: Recognizer<Token, any>): Token | undefined;
|
77 | protected setOffendingToken<TSymbol extends Token>(recognizer: Recognizer<TSymbol, any>, offendingToken?: TSymbol): void;
|
78 | /**
|
79 | * Gets the {@link Recognizer} where this exception occurred.
|
80 | *
|
81 | * If the recognizer is not available, this method returns `undefined`.
|
82 | *
|
83 | * @returns The recognizer where this exception occurred, or `undefined` if
|
84 | * the recognizer is not available.
|
85 | */
|
86 | get recognizer(): Recognizer<any, any> | undefined;
|
87 | }
|