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 { ANTLRErrorListener } from "./ANTLRErrorListener";
|
6 | import { ATN } from "./atn/ATN";
|
7 | import { ATNSimulator } from "./atn/ATNSimulator";
|
8 | import { IntStream } from "./IntStream";
|
9 | import { ParseInfo } from "./atn/ParseInfo";
|
10 | import { RecognitionException } from "./RecognitionException";
|
11 | import { RuleContext } from "./RuleContext";
|
12 | import { Vocabulary } from "./Vocabulary";
|
13 | export declare abstract class Recognizer<TSymbol, ATNInterpreter extends ATNSimulator> {
|
14 | static readonly EOF: number;
|
15 | private static tokenTypeMapCache;
|
16 | private static ruleIndexMapCache;
|
17 | private readonly _listeners;
|
18 | protected _interp: ATNInterpreter;
|
19 | private _stateNumber;
|
20 | abstract readonly ruleNames: string[];
|
21 | /**
|
22 | * Get the vocabulary used by the recognizer.
|
23 | *
|
24 | * @returns A {@link Vocabulary} instance providing information about the
|
25 | * vocabulary used by the grammar.
|
26 | */
|
27 | abstract readonly vocabulary: Vocabulary;
|
28 | /**
|
29 | * Get a map from token names to token types.
|
30 | *
|
31 | * Used for XPath and tree pattern compilation.
|
32 | */
|
33 | getTokenTypeMap(): ReadonlyMap<string, number>;
|
34 | /**
|
35 | * Get a map from rule names to rule indexes.
|
36 | *
|
37 | * Used for XPath and tree pattern compilation.
|
38 | */
|
39 | getRuleIndexMap(): ReadonlyMap<string, number>;
|
40 | getTokenType(tokenName: string): number;
|
41 | /**
|
42 | * If this recognizer was generated, it will have a serialized ATN
|
43 | * representation of the grammar.
|
44 | *
|
45 | * For interpreters, we don't know their serialized ATN despite having
|
46 | * created the interpreter from it.
|
47 | */
|
48 | get serializedATN(): string;
|
49 | /** For debugging and other purposes, might want the grammar name.
|
50 | * Have ANTLR generate an implementation for this method.
|
51 | */
|
52 | abstract readonly grammarFileName: string;
|
53 | /**
|
54 | * Get the {@link ATN} used by the recognizer for prediction.
|
55 | *
|
56 | * @returns The {@link ATN} used by the recognizer for prediction.
|
57 | */
|
58 | get atn(): ATN;
|
59 | /**
|
60 | * Get the ATN interpreter used by the recognizer for prediction.
|
61 | *
|
62 | * @returns The ATN interpreter used by the recognizer for prediction.
|
63 | */
|
64 | get interpreter(): ATNInterpreter;
|
65 | /**
|
66 | * Set the ATN interpreter used by the recognizer for prediction.
|
67 | *
|
68 | * @param interpreter The ATN interpreter used by the recognizer for
|
69 | * prediction.
|
70 | */
|
71 | set interpreter(interpreter: ATNInterpreter);
|
72 | /** If profiling during the parse/lex, this will return DecisionInfo records
|
73 | * for each decision in recognizer in a ParseInfo object.
|
74 | *
|
75 | * @since 4.3
|
76 | */
|
77 | get parseInfo(): Promise<ParseInfo | undefined>;
|
78 | /** What is the error header, normally line/character position information? */
|
79 | getErrorHeader(e: RecognitionException): string;
|
80 | /**
|
81 | * @exception NullPointerException if `listener` is `undefined`.
|
82 | */
|
83 | addErrorListener(listener: ANTLRErrorListener<TSymbol>): void;
|
84 | removeErrorListener(listener: ANTLRErrorListener<TSymbol>): void;
|
85 | removeErrorListeners(): void;
|
86 | getErrorListeners(): Array<ANTLRErrorListener<TSymbol>>;
|
87 | getErrorListenerDispatch(): ANTLRErrorListener<TSymbol>;
|
88 | sempred(_localctx: RuleContext | undefined, ruleIndex: number, actionIndex: number): boolean;
|
89 | precpred(localctx: RuleContext | undefined, precedence: number): boolean;
|
90 | action(_localctx: RuleContext | undefined, ruleIndex: number, actionIndex: number): void;
|
91 | get state(): number;
|
92 | /** Indicate that the recognizer has changed internal state that is
|
93 | * consistent with the ATN state passed in. This way we always know
|
94 | * where we are in the ATN as the parser goes along. The rule
|
95 | * context objects form a stack that lets us see the stack of
|
96 | * invoking rules. Combine this and we have complete ATN
|
97 | * configuration information.
|
98 | */
|
99 | set state(atnState: number);
|
100 | abstract readonly inputStream: IntStream | undefined;
|
101 | }
|