@opra/client 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/typings/antlr4ts/ANTLRErrorListener.d.ts +43 -0
- package/typings/antlr4ts/ANTLRErrorStrategy.d.ts +109 -0
- package/typings/antlr4ts/ANTLRInputStream.d.ts +51 -0
- package/typings/antlr4ts/BailErrorStrategy.d.ts +48 -0
- package/typings/antlr4ts/BufferedTokenStream.d.ts +143 -0
- package/typings/antlr4ts/CharStream.d.ts +26 -0
- package/typings/antlr4ts/CharStreams.d.ts +54 -0
- package/typings/antlr4ts/CodePointBuffer.d.ts +40 -0
- package/typings/antlr4ts/CodePointCharStream.d.ts +45 -0
- package/typings/antlr4ts/CommonToken.d.ts +116 -0
- package/typings/antlr4ts/CommonTokenFactory.d.ts +53 -0
- package/typings/antlr4ts/CommonTokenStream.d.ts +52 -0
- package/typings/antlr4ts/ConsoleErrorListener.d.ts +29 -0
- package/typings/antlr4ts/Decorators.d.ts +8 -0
- package/typings/antlr4ts/DefaultErrorStrategy.d.ts +347 -0
- package/typings/antlr4ts/Dependents.d.ts +69 -0
- package/typings/antlr4ts/DiagnosticErrorListener.d.ts +60 -0
- package/typings/antlr4ts/FailedPredicateException.d.ts +21 -0
- package/typings/antlr4ts/InputMismatchException.d.ts +14 -0
- package/typings/antlr4ts/IntStream.d.ts +197 -0
- package/typings/antlr4ts/InterpreterRuleContext.d.ts +33 -0
- package/typings/antlr4ts/Lexer.d.ts +141 -0
- package/typings/antlr4ts/LexerInterpreter.d.ts +23 -0
- package/typings/antlr4ts/LexerNoViableAltException.d.ts +19 -0
- package/typings/antlr4ts/ListTokenSource.d.ts +86 -0
- package/typings/antlr4ts/NoViableAltException.d.ts +30 -0
- package/typings/antlr4ts/Parser.d.ts +372 -0
- package/typings/antlr4ts/ParserErrorListener.d.ts +112 -0
- package/typings/antlr4ts/ParserInterpreter.d.ts +151 -0
- package/typings/antlr4ts/ParserRuleContext.d.ts +169 -0
- package/typings/antlr4ts/ProxyErrorListener.d.ts +20 -0
- package/typings/antlr4ts/ProxyParserErrorListener.d.ts +21 -0
- package/typings/antlr4ts/RecognitionException.d.ts +87 -0
- package/typings/antlr4ts/Recognizer.d.ts +101 -0
- package/typings/antlr4ts/RuleContext.d.ts +124 -0
- package/typings/antlr4ts/RuleContextWithAltNum.d.ts +22 -0
- package/typings/antlr4ts/RuleDependency.d.ts +32 -0
- package/typings/antlr4ts/RuleVersion.d.ts +11 -0
- package/typings/antlr4ts/Token.d.ts +83 -0
- package/typings/antlr4ts/TokenFactory.d.ts +23 -0
- package/typings/antlr4ts/TokenSource.d.ts +67 -0
- package/typings/antlr4ts/TokenStream.d.ts +145 -0
- package/typings/antlr4ts/TokenStreamRewriter.d.ts +216 -0
- package/typings/antlr4ts/Vocabulary.d.ts +117 -0
- package/typings/antlr4ts/VocabularyImpl.d.ts +47 -0
- package/typings/antlr4ts/WritableToken.d.ts +13 -0
- package/typings/antlr4ts/atn/ATN.d.ts +123 -0
- package/typings/antlr4ts/atn/ATNConfig.d.ts +140 -0
- package/typings/antlr4ts/atn/ATNConfigSet.d.ts +113 -0
- package/typings/antlr4ts/atn/ATNDeserializationOptions.d.ts +26 -0
- package/typings/antlr4ts/atn/ATNDeserializer.d.ts +86 -0
- package/typings/antlr4ts/atn/ATNSimulator.d.ts +28 -0
- package/typings/antlr4ts/atn/ATNState.d.ts +111 -0
- package/typings/antlr4ts/atn/ATNStateType.d.ts +19 -0
- package/typings/antlr4ts/atn/ATNType.d.ts +19 -0
- package/typings/antlr4ts/atn/AbstractPredicateTransition.d.ts +13 -0
- package/typings/antlr4ts/atn/ActionTransition.d.ts +17 -0
- package/typings/antlr4ts/atn/AmbiguityInfo.d.ts +60 -0
- package/typings/antlr4ts/atn/AtomTransition.d.ts +18 -0
- package/typings/antlr4ts/atn/BasicBlockStartState.d.ts +13 -0
- package/typings/antlr4ts/atn/BasicState.d.ts +13 -0
- package/typings/antlr4ts/atn/BlockEndState.d.ts +12 -0
- package/typings/antlr4ts/atn/BlockStartState.d.ts +10 -0
- package/typings/antlr4ts/atn/CodePointTransitions.d.ts +27 -0
- package/typings/antlr4ts/atn/ConflictInfo.d.ts +35 -0
- package/typings/antlr4ts/atn/ContextSensitivityInfo.d.ts +39 -0
- package/typings/antlr4ts/atn/DecisionEventInfo.d.ts +54 -0
- package/typings/antlr4ts/atn/DecisionInfo.d.ts +201 -0
- package/typings/antlr4ts/atn/DecisionState.d.ts +10 -0
- package/typings/antlr4ts/atn/EpsilonTransition.d.ts +24 -0
- package/typings/antlr4ts/atn/ErrorInfo.d.ts +32 -0
- package/typings/antlr4ts/atn/InvalidState.d.ts +13 -0
- package/typings/antlr4ts/atn/LL1Analyzer.d.ts +98 -0
- package/typings/antlr4ts/atn/LexerATNSimulator.d.ts +153 -0
- package/typings/antlr4ts/atn/LexerAction.d.ts +47 -0
- package/typings/antlr4ts/atn/LexerActionExecutor.d.ts +104 -0
- package/typings/antlr4ts/atn/LexerActionType.d.ts +44 -0
- package/typings/antlr4ts/atn/LexerChannelAction.d.ts +48 -0
- package/typings/antlr4ts/atn/LexerCustomAction.d.ts +73 -0
- package/typings/antlr4ts/atn/LexerIndexedCustomAction.d.ts +74 -0
- package/typings/antlr4ts/atn/LexerModeAction.d.ts +48 -0
- package/typings/antlr4ts/atn/LexerMoreAction.d.ts +47 -0
- package/typings/antlr4ts/atn/LexerPopModeAction.d.ts +47 -0
- package/typings/antlr4ts/atn/LexerPushModeAction.d.ts +48 -0
- package/typings/antlr4ts/atn/LexerSkipAction.d.ts +47 -0
- package/typings/antlr4ts/atn/LexerTypeAction.d.ts +47 -0
- package/typings/antlr4ts/atn/LookaheadEventInfo.d.ts +37 -0
- package/typings/antlr4ts/atn/LoopEndState.d.ts +11 -0
- package/typings/antlr4ts/atn/NotSetTransition.d.ts +14 -0
- package/typings/antlr4ts/atn/OrderedATNConfigSet.d.ts +23 -0
- package/typings/antlr4ts/atn/ParseInfo.d.ts +79 -0
- package/typings/antlr4ts/atn/ParserATNSimulator.d.ts +567 -0
- package/typings/antlr4ts/atn/PlusBlockStartState.d.ts +16 -0
- package/typings/antlr4ts/atn/PlusLoopbackState.d.ts +12 -0
- package/typings/antlr4ts/atn/PrecedencePredicateTransition.d.ts +21 -0
- package/typings/antlr4ts/atn/PredicateEvalInfo.d.ts +54 -0
- package/typings/antlr4ts/atn/PredicateTransition.d.ts +25 -0
- package/typings/antlr4ts/atn/PredictionContext.d.ts +89 -0
- package/typings/antlr4ts/atn/PredictionContextCache.d.ts +40 -0
- package/typings/antlr4ts/atn/PredictionMode.d.ts +89 -0
- package/typings/antlr4ts/atn/ProfilingATNSimulator.d.ts +55 -0
- package/typings/antlr4ts/atn/RangeTransition.d.ts +17 -0
- package/typings/antlr4ts/atn/RuleStartState.d.ts +13 -0
- package/typings/antlr4ts/atn/RuleStopState.d.ts +15 -0
- package/typings/antlr4ts/atn/RuleTransition.d.ts +22 -0
- package/typings/antlr4ts/atn/SemanticContext.d.ts +143 -0
- package/typings/antlr4ts/atn/SetTransition.d.ts +17 -0
- package/typings/antlr4ts/atn/SimulatorState.d.ts +17 -0
- package/typings/antlr4ts/atn/StarBlockStartState.d.ts +10 -0
- package/typings/antlr4ts/atn/StarLoopEntryState.d.ts +37 -0
- package/typings/antlr4ts/atn/StarLoopbackState.d.ts +11 -0
- package/typings/antlr4ts/atn/TokensStartState.d.ts +10 -0
- package/typings/antlr4ts/atn/Transition.d.ts +38 -0
- package/typings/antlr4ts/atn/TransitionType.d.ts +16 -0
- package/typings/antlr4ts/atn/WildcardTransition.d.ts +13 -0
- package/typings/antlr4ts/atn/index.d.ts +73 -0
- package/typings/antlr4ts/dfa/AcceptStateInfo.d.ts +33 -0
- package/typings/antlr4ts/dfa/DFA.d.ts +94 -0
- package/typings/antlr4ts/dfa/DFASerializer.d.ts +23 -0
- package/typings/antlr4ts/dfa/DFAState.d.ts +95 -0
- package/typings/antlr4ts/dfa/LexerDFASerializer.d.ts +10 -0
- package/typings/antlr4ts/dfa/index.d.ts +9 -0
- package/typings/antlr4ts/index.d.ts +49 -0
- package/typings/antlr4ts/misc/Args.d.ts +13 -0
- package/typings/antlr4ts/misc/Array2DHashMap.d.ts +20 -0
- package/typings/antlr4ts/misc/Array2DHashSet.d.ts +62 -0
- package/typings/antlr4ts/misc/ArrayEqualityComparator.d.ts +32 -0
- package/typings/antlr4ts/misc/Arrays.d.ts +18 -0
- package/typings/antlr4ts/misc/BitSet.d.ts +268 -0
- package/typings/antlr4ts/misc/Character.d.ts +7 -0
- package/typings/antlr4ts/misc/DefaultEqualityComparator.d.ts +31 -0
- package/typings/antlr4ts/misc/EqualityComparator.d.ts +29 -0
- package/typings/antlr4ts/misc/IntSet.d.ts +129 -0
- package/typings/antlr4ts/misc/IntegerList.d.ts +69 -0
- package/typings/antlr4ts/misc/IntegerStack.d.ts +15 -0
- package/typings/antlr4ts/misc/InterpreterDataReader.d.ts +39 -0
- package/typings/antlr4ts/misc/Interval.d.ts +57 -0
- package/typings/antlr4ts/misc/IntervalSet.d.ts +96 -0
- package/typings/antlr4ts/misc/MultiMap.d.ts +9 -0
- package/typings/antlr4ts/misc/MurmurHash.d.ts +45 -0
- package/typings/antlr4ts/misc/ObjectEqualityComparator.d.ts +32 -0
- package/typings/antlr4ts/misc/ParseCancellationException.d.ts +18 -0
- package/typings/antlr4ts/misc/Stubs.d.ts +31 -0
- package/typings/antlr4ts/misc/UUID.d.ts +13 -0
- package/typings/antlr4ts/misc/Utils.d.ts +15 -0
- package/typings/antlr4ts/misc/index.d.ts +25 -0
- package/typings/antlr4ts/tree/AbstractParseTreeVisitor.d.ts +103 -0
- package/typings/antlr4ts/tree/ErrorNode.d.ts +17 -0
- package/typings/antlr4ts/tree/ParseTree.d.ts +36 -0
- package/typings/antlr4ts/tree/ParseTreeListener.d.ts +26 -0
- package/typings/antlr4ts/tree/ParseTreeProperty.d.ts +28 -0
- package/typings/antlr4ts/tree/ParseTreeVisitor.d.ts +48 -0
- package/typings/antlr4ts/tree/ParseTreeWalker.d.ts +35 -0
- package/typings/antlr4ts/tree/RuleNode.d.ts +21 -0
- package/typings/antlr4ts/tree/SyntaxTree.d.ts +29 -0
- package/typings/antlr4ts/tree/TerminalNode.d.ts +27 -0
- package/typings/antlr4ts/tree/Tree.d.ts +36 -0
- package/typings/antlr4ts/tree/Trees.d.ts +75 -0
- package/typings/antlr4ts/tree/index.d.ts +16 -0
- package/typings/antlr4ts/tree/pattern/Chunk.d.ts +17 -0
- package/typings/antlr4ts/tree/pattern/ParseTreeMatch.d.ts +124 -0
- package/typings/antlr4ts/tree/pattern/ParseTreePattern.d.ts +98 -0
- package/typings/antlr4ts/tree/pattern/ParseTreePatternMatcher.d.ts +166 -0
- package/typings/antlr4ts/tree/pattern/RuleTagToken.d.ts +122 -0
- package/typings/antlr4ts/tree/pattern/TagChunk.d.ts +59 -0
- package/typings/antlr4ts/tree/pattern/TextChunk.d.ts +35 -0
- package/typings/antlr4ts/tree/pattern/TokenTagToken.d.ts +56 -0
- package/typings/antlr4ts/tree/pattern/index.d.ts +9 -0
- package/typings/antlr4ts/tree/xpath/XPath.d.ts +66 -0
- package/typings/antlr4ts/tree/xpath/XPathElement.d.ts +19 -0
- package/typings/antlr4ts/tree/xpath/XPathLexer.d.ts +36 -0
- package/typings/antlr4ts/tree/xpath/XPathLexerErrorListener.d.ts +10 -0
- package/typings/antlr4ts/tree/xpath/XPathRuleAnywhereElement.d.ts +14 -0
- package/typings/antlr4ts/tree/xpath/XPathRuleElement.d.ts +11 -0
- package/typings/antlr4ts/tree/xpath/XPathTokenAnywhereElement.d.ts +11 -0
- package/typings/antlr4ts/tree/xpath/XPathTokenElement.d.ts +11 -0
- package/typings/antlr4ts/tree/xpath/XPathWildcardAnywhereElement.d.ts +10 -0
- package/typings/antlr4ts/tree/xpath/XPathWildcardElement.d.ts +10 -0
- package/typings/antlr4ts/tree/xpath/index.d.ts +14 -0
- package/typings/common/filter/antlr/OpraFilterLexer.d.ts +4 -4
- package/typings/common/filter/antlr/OpraFilterParser.d.ts +8 -8
- package/typings/common/filter/antlr/OpraFilterVisitor.d.ts +1 -1
- package/typings/common/filter/error-listener.d.ts +2 -2
- package/typings/common/filter/errors.d.ts +2 -2
- package/typings/common/filter/filter-tree-visitor.d.ts +1 -1
- package/typings/common/filter/parse.d.ts +1 -1
|
@@ -0,0 +1,372 @@
|
|
|
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 { ANTLRErrorStrategy } from "./ANTLRErrorStrategy";
|
|
6
|
+
import { ATN } from "./atn/ATN";
|
|
7
|
+
import { ErrorNode } from "./tree/ErrorNode";
|
|
8
|
+
import { IntegerStack } from "./misc/IntegerStack";
|
|
9
|
+
import { IntervalSet } from "./misc/IntervalSet";
|
|
10
|
+
import { Lexer } from "./Lexer";
|
|
11
|
+
import { ParseInfo } from "./atn/ParseInfo";
|
|
12
|
+
import { ParserATNSimulator } from "./atn/ParserATNSimulator";
|
|
13
|
+
import { ParserErrorListener } from "./ParserErrorListener";
|
|
14
|
+
import { ParserRuleContext } from "./ParserRuleContext";
|
|
15
|
+
import { ParseTreeListener } from "./tree/ParseTreeListener";
|
|
16
|
+
import { ParseTreePattern } from "./tree/pattern/ParseTreePattern";
|
|
17
|
+
import { RecognitionException } from "./RecognitionException";
|
|
18
|
+
import { Recognizer } from "./Recognizer";
|
|
19
|
+
import { RuleContext } from "./RuleContext";
|
|
20
|
+
import { TerminalNode } from "./tree/TerminalNode";
|
|
21
|
+
import { Token } from "./Token";
|
|
22
|
+
import { TokenFactory } from "./TokenFactory";
|
|
23
|
+
import { TokenStream } from "./TokenStream";
|
|
24
|
+
/** This is all the parsing support code essentially; most of it is error recovery stuff. */
|
|
25
|
+
export declare abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|
26
|
+
/**
|
|
27
|
+
* This field maps from the serialized ATN string to the deserialized {@link ATN} with
|
|
28
|
+
* bypass alternatives.
|
|
29
|
+
*
|
|
30
|
+
* @see ATNDeserializationOptions.isGenerateRuleBypassTransitions
|
|
31
|
+
*/
|
|
32
|
+
private static readonly bypassAltsAtnCache;
|
|
33
|
+
/**
|
|
34
|
+
* The error handling strategy for the parser. The default value is a new
|
|
35
|
+
* instance of {@link DefaultErrorStrategy}.
|
|
36
|
+
*
|
|
37
|
+
* @see #getErrorHandler
|
|
38
|
+
* @see #setErrorHandler
|
|
39
|
+
*/
|
|
40
|
+
protected _errHandler: ANTLRErrorStrategy;
|
|
41
|
+
/**
|
|
42
|
+
* The input stream.
|
|
43
|
+
*
|
|
44
|
+
* @see #getInputStream
|
|
45
|
+
* @see #setInputStream
|
|
46
|
+
*/
|
|
47
|
+
protected _input: TokenStream;
|
|
48
|
+
protected readonly _precedenceStack: IntegerStack;
|
|
49
|
+
/**
|
|
50
|
+
* The {@link ParserRuleContext} object for the currently executing rule.
|
|
51
|
+
*
|
|
52
|
+
* This is always non-undefined during the parsing process.
|
|
53
|
+
*/
|
|
54
|
+
protected _ctx: ParserRuleContext;
|
|
55
|
+
/**
|
|
56
|
+
* Specifies whether or not the parser should construct a parse tree during
|
|
57
|
+
* the parsing process. The default value is `true`.
|
|
58
|
+
*
|
|
59
|
+
* @see `buildParseTree`
|
|
60
|
+
*/
|
|
61
|
+
private _buildParseTrees;
|
|
62
|
+
/**
|
|
63
|
+
* When {@link #setTrace}`(true)` is called, a reference to the
|
|
64
|
+
* {@link TraceListener} is stored here so it can be easily removed in a
|
|
65
|
+
* later call to {@link #setTrace}`(false)`. The listener itself is
|
|
66
|
+
* implemented as a parser listener so this field is not directly used by
|
|
67
|
+
* other parser methods.
|
|
68
|
+
*/
|
|
69
|
+
private _tracer;
|
|
70
|
+
/**
|
|
71
|
+
* The list of {@link ParseTreeListener} listeners registered to receive
|
|
72
|
+
* events during the parse.
|
|
73
|
+
*
|
|
74
|
+
* @see #addParseListener
|
|
75
|
+
*/
|
|
76
|
+
protected _parseListeners: ParseTreeListener[];
|
|
77
|
+
/**
|
|
78
|
+
* The number of syntax errors reported during parsing. This value is
|
|
79
|
+
* incremented each time {@link #notifyErrorListeners} is called.
|
|
80
|
+
*/
|
|
81
|
+
protected _syntaxErrors: number;
|
|
82
|
+
/** Indicates parser has match()ed EOF token. See {@link #exitRule()}. */
|
|
83
|
+
protected matchedEOF: boolean;
|
|
84
|
+
constructor(input: TokenStream);
|
|
85
|
+
/** reset the parser's state */
|
|
86
|
+
reset(): void;
|
|
87
|
+
reset(resetInput: boolean): void;
|
|
88
|
+
/**
|
|
89
|
+
* Match current input symbol against `ttype`. If the symbol type
|
|
90
|
+
* matches, {@link ANTLRErrorStrategy#reportMatch} and {@link #consume} are
|
|
91
|
+
* called to complete the match process.
|
|
92
|
+
*
|
|
93
|
+
* If the symbol type does not match,
|
|
94
|
+
* {@link ANTLRErrorStrategy#recoverInline} is called on the current error
|
|
95
|
+
* strategy to attempt recovery. If {@link #getBuildParseTree} is
|
|
96
|
+
* `true` and the token index of the symbol returned by
|
|
97
|
+
* {@link ANTLRErrorStrategy#recoverInline} is -1, the symbol is added to
|
|
98
|
+
* the parse tree by calling {@link #createErrorNode(ParserRuleContext, Token)} then
|
|
99
|
+
* {@link ParserRuleContext#addErrorNode(ErrorNode)}.
|
|
100
|
+
*
|
|
101
|
+
* @param ttype the token type to match
|
|
102
|
+
* @returns the matched symbol
|
|
103
|
+
* @ if the current input symbol did not match
|
|
104
|
+
* `ttype` and the error strategy could not recover from the
|
|
105
|
+
* mismatched symbol
|
|
106
|
+
*/
|
|
107
|
+
match(ttype: number): Token;
|
|
108
|
+
/**
|
|
109
|
+
* Match current input symbol as a wildcard. If the symbol type matches
|
|
110
|
+
* (i.e. has a value greater than 0), {@link ANTLRErrorStrategy#reportMatch}
|
|
111
|
+
* and {@link #consume} are called to complete the match process.
|
|
112
|
+
*
|
|
113
|
+
* If the symbol type does not match,
|
|
114
|
+
* {@link ANTLRErrorStrategy#recoverInline} is called on the current error
|
|
115
|
+
* strategy to attempt recovery. If {@link #getBuildParseTree} is
|
|
116
|
+
* `true` and the token index of the symbol returned by
|
|
117
|
+
* {@link ANTLRErrorStrategy#recoverInline} is -1, the symbol is added to
|
|
118
|
+
* the parse tree by calling {@link Parser#createErrorNode(ParserRuleContext, Token)} then
|
|
119
|
+
* {@link ParserRuleContext#addErrorNode(ErrorNode)}.
|
|
120
|
+
*
|
|
121
|
+
* @returns the matched symbol
|
|
122
|
+
* @ if the current input symbol did not match
|
|
123
|
+
* a wildcard and the error strategy could not recover from the mismatched
|
|
124
|
+
* symbol
|
|
125
|
+
*/
|
|
126
|
+
matchWildcard(): Token;
|
|
127
|
+
/**
|
|
128
|
+
* Track the {@link ParserRuleContext} objects during the parse and hook
|
|
129
|
+
* them up using the {@link ParserRuleContext#children} list so that it
|
|
130
|
+
* forms a parse tree. The {@link ParserRuleContext} returned from the start
|
|
131
|
+
* rule represents the root of the parse tree.
|
|
132
|
+
*
|
|
133
|
+
* Note that if we are not building parse trees, rule contexts only point
|
|
134
|
+
* upwards. When a rule exits, it returns the context but that gets garbage
|
|
135
|
+
* collected if nobody holds a reference. It points upwards but nobody
|
|
136
|
+
* points at it.
|
|
137
|
+
*
|
|
138
|
+
* When we build parse trees, we are adding all of these contexts to
|
|
139
|
+
* {@link ParserRuleContext#children} list. Contexts are then not candidates
|
|
140
|
+
* for garbage collection.
|
|
141
|
+
*/
|
|
142
|
+
set buildParseTree(buildParseTrees: boolean);
|
|
143
|
+
/**
|
|
144
|
+
* Gets whether or not a complete parse tree will be constructed while
|
|
145
|
+
* parsing. This property is `true` for a newly constructed parser.
|
|
146
|
+
*
|
|
147
|
+
* @returns `true` if a complete parse tree will be constructed while
|
|
148
|
+
* parsing, otherwise `false`
|
|
149
|
+
*/
|
|
150
|
+
get buildParseTree(): boolean;
|
|
151
|
+
getParseListeners(): ParseTreeListener[];
|
|
152
|
+
/**
|
|
153
|
+
* Registers `listener` to receive events during the parsing process.
|
|
154
|
+
*
|
|
155
|
+
* To support output-preserving grammar transformations (including but not
|
|
156
|
+
* limited to left-recursion removal, automated left-factoring, and
|
|
157
|
+
* optimized code generation), calls to listener methods during the parse
|
|
158
|
+
* may differ substantially from calls made by
|
|
159
|
+
* {@link ParseTreeWalker#DEFAULT} used after the parse is complete. In
|
|
160
|
+
* particular, rule entry and exit events may occur in a different order
|
|
161
|
+
* during the parse than after the parser. In addition, calls to certain
|
|
162
|
+
* rule entry methods may be omitted.
|
|
163
|
+
*
|
|
164
|
+
* With the following specific exceptions, calls to listener events are
|
|
165
|
+
* *deterministic*, i.e. for identical input the calls to listener
|
|
166
|
+
* methods will be the same.
|
|
167
|
+
*
|
|
168
|
+
* * Alterations to the grammar used to generate code may change the
|
|
169
|
+
* behavior of the listener calls.
|
|
170
|
+
* * Alterations to the command line options passed to ANTLR 4 when
|
|
171
|
+
* generating the parser may change the behavior of the listener calls.
|
|
172
|
+
* * Changing the version of the ANTLR Tool used to generate the parser
|
|
173
|
+
* may change the behavior of the listener calls.
|
|
174
|
+
*
|
|
175
|
+
* @param listener the listener to add
|
|
176
|
+
*
|
|
177
|
+
* @throws {@link TypeError} if `listener` is `undefined`
|
|
178
|
+
*/
|
|
179
|
+
addParseListener(listener: ParseTreeListener): void;
|
|
180
|
+
/**
|
|
181
|
+
* Remove `listener` from the list of parse listeners.
|
|
182
|
+
*
|
|
183
|
+
* If `listener` is `undefined` or has not been added as a parse
|
|
184
|
+
* listener, this method does nothing.
|
|
185
|
+
*
|
|
186
|
+
* @see #addParseListener
|
|
187
|
+
*
|
|
188
|
+
* @param listener the listener to remove
|
|
189
|
+
*/
|
|
190
|
+
removeParseListener(listener: ParseTreeListener): void;
|
|
191
|
+
/**
|
|
192
|
+
* Remove all parse listeners.
|
|
193
|
+
*
|
|
194
|
+
* @see #addParseListener
|
|
195
|
+
*/
|
|
196
|
+
removeParseListeners(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Notify any parse listeners of an enter rule event.
|
|
199
|
+
*
|
|
200
|
+
* @see #addParseListener
|
|
201
|
+
*/
|
|
202
|
+
protected triggerEnterRuleEvent(): void;
|
|
203
|
+
/**
|
|
204
|
+
* Notify any parse listeners of an exit rule event.
|
|
205
|
+
*
|
|
206
|
+
* @see #addParseListener
|
|
207
|
+
*/
|
|
208
|
+
protected triggerExitRuleEvent(): void;
|
|
209
|
+
/**
|
|
210
|
+
* Gets the number of syntax errors reported during parsing. This value is
|
|
211
|
+
* incremented each time {@link #notifyErrorListeners} is called.
|
|
212
|
+
*
|
|
213
|
+
* @see #notifyErrorListeners
|
|
214
|
+
*/
|
|
215
|
+
get numberOfSyntaxErrors(): number;
|
|
216
|
+
get tokenFactory(): TokenFactory;
|
|
217
|
+
/**
|
|
218
|
+
* The ATN with bypass alternatives is expensive to create so we create it
|
|
219
|
+
* lazily.
|
|
220
|
+
*
|
|
221
|
+
* @ if the current parser does not
|
|
222
|
+
* implement the `serializedATN` property.
|
|
223
|
+
*/
|
|
224
|
+
getATNWithBypassAlts(): ATN;
|
|
225
|
+
/**
|
|
226
|
+
* The preferred method of getting a tree pattern. For example, here's a
|
|
227
|
+
* sample use:
|
|
228
|
+
*
|
|
229
|
+
* ```
|
|
230
|
+
* let t: ParseTree = parser.expr();
|
|
231
|
+
* let p: ParseTreePattern = await parser.compileParseTreePattern("<ID>+0", MyParser.RULE_expr);
|
|
232
|
+
* let m: ParseTreeMatch = p.match(t);
|
|
233
|
+
* let id: string = m.get("ID");
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
compileParseTreePattern(pattern: string, patternRuleIndex: number): Promise<ParseTreePattern>;
|
|
237
|
+
/**
|
|
238
|
+
* The same as {@link #compileParseTreePattern(String, int)} but specify a
|
|
239
|
+
* {@link Lexer} rather than trying to deduce it from this parser.
|
|
240
|
+
*/
|
|
241
|
+
compileParseTreePattern(pattern: string, patternRuleIndex: number, lexer?: Lexer): Promise<ParseTreePattern>;
|
|
242
|
+
get errorHandler(): ANTLRErrorStrategy;
|
|
243
|
+
set errorHandler(handler: ANTLRErrorStrategy);
|
|
244
|
+
get inputStream(): TokenStream;
|
|
245
|
+
/** Set the token stream and reset the parser. */
|
|
246
|
+
set inputStream(input: TokenStream);
|
|
247
|
+
/** Match needs to return the current input symbol, which gets put
|
|
248
|
+
* into the label for the associated token ref; e.g., x=ID.
|
|
249
|
+
*/
|
|
250
|
+
get currentToken(): Token;
|
|
251
|
+
notifyErrorListeners(/*@NotNull*/ msg: string): void;
|
|
252
|
+
notifyErrorListeners(/*@NotNull*/ msg: string, /*@NotNull*/ offendingToken: Token | null, e: RecognitionException | undefined): void;
|
|
253
|
+
/**
|
|
254
|
+
* Consume and return the [current symbol](`currentToken`).
|
|
255
|
+
*
|
|
256
|
+
* E.g., given the following input with `A` being the current
|
|
257
|
+
* lookahead symbol, this function moves the cursor to `B` and returns
|
|
258
|
+
* `A`.
|
|
259
|
+
*
|
|
260
|
+
* ```
|
|
261
|
+
* A B
|
|
262
|
+
* ^
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* If the parser is not in error recovery mode, the consumed symbol is added
|
|
266
|
+
* to the parse tree using {@link ParserRuleContext#addChild(TerminalNode)}, and
|
|
267
|
+
* {@link ParseTreeListener#visitTerminal} is called on any parse listeners.
|
|
268
|
+
* If the parser *is* in error recovery mode, the consumed symbol is
|
|
269
|
+
* added to the parse tree using {@link #createErrorNode(ParserRuleContext, Token)} then
|
|
270
|
+
* {@link ParserRuleContext#addErrorNode(ErrorNode)} and
|
|
271
|
+
* {@link ParseTreeListener#visitErrorNode} is called on any parse
|
|
272
|
+
* listeners.
|
|
273
|
+
*/
|
|
274
|
+
consume(): Token;
|
|
275
|
+
/**
|
|
276
|
+
* How to create a token leaf node associated with a parent.
|
|
277
|
+
* Typically, the terminal node to create is not a function of the parent.
|
|
278
|
+
*
|
|
279
|
+
* @since 4.7
|
|
280
|
+
*/
|
|
281
|
+
createTerminalNode(parent: ParserRuleContext, t: Token): TerminalNode;
|
|
282
|
+
/**
|
|
283
|
+
* How to create an error node, given a token, associated with a parent.
|
|
284
|
+
* Typically, the error node to create is not a function of the parent.
|
|
285
|
+
*
|
|
286
|
+
* @since 4.7
|
|
287
|
+
*/
|
|
288
|
+
createErrorNode(parent: ParserRuleContext, t: Token): ErrorNode;
|
|
289
|
+
protected addContextToParseTree(): void;
|
|
290
|
+
/**
|
|
291
|
+
* Always called by generated parsers upon entry to a rule. Access field
|
|
292
|
+
* {@link #_ctx} get the current context.
|
|
293
|
+
*/
|
|
294
|
+
enterRule(localctx: ParserRuleContext, state: number, ruleIndex: number): void;
|
|
295
|
+
enterLeftFactoredRule(localctx: ParserRuleContext, state: number, ruleIndex: number): void;
|
|
296
|
+
exitRule(): void;
|
|
297
|
+
enterOuterAlt(localctx: ParserRuleContext, altNum: number): void;
|
|
298
|
+
/**
|
|
299
|
+
* Get the precedence level for the top-most precedence rule.
|
|
300
|
+
*
|
|
301
|
+
* @returns The precedence level for the top-most precedence rule, or -1 if
|
|
302
|
+
* the parser context is not nested within a precedence rule.
|
|
303
|
+
*/
|
|
304
|
+
get precedence(): number;
|
|
305
|
+
enterRecursionRule(localctx: ParserRuleContext, state: number, ruleIndex: number, precedence: number): void;
|
|
306
|
+
/** Like {@link #enterRule} but for recursive rules.
|
|
307
|
+
* Make the current context the child of the incoming localctx.
|
|
308
|
+
*/
|
|
309
|
+
pushNewRecursionContext(localctx: ParserRuleContext, state: number, ruleIndex: number): void;
|
|
310
|
+
unrollRecursionContexts(_parentctx: ParserRuleContext): void;
|
|
311
|
+
getInvokingContext(ruleIndex: number): ParserRuleContext | undefined;
|
|
312
|
+
get context(): ParserRuleContext;
|
|
313
|
+
set context(ctx: ParserRuleContext);
|
|
314
|
+
precpred(localctx: RuleContext, precedence: number): boolean;
|
|
315
|
+
getErrorListenerDispatch(): ParserErrorListener;
|
|
316
|
+
inContext(context: string): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Checks whether or not `symbol` can follow the current state in the
|
|
319
|
+
* ATN. The behavior of this method is equivalent to the following, but is
|
|
320
|
+
* implemented such that the complete context-sensitive follow set does not
|
|
321
|
+
* need to be explicitly constructed.
|
|
322
|
+
*
|
|
323
|
+
* ```
|
|
324
|
+
* return getExpectedTokens().contains(symbol);
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* @param symbol the symbol type to check
|
|
328
|
+
* @returns `true` if `symbol` can follow the current state in
|
|
329
|
+
* the ATN, otherwise `false`.
|
|
330
|
+
*/
|
|
331
|
+
isExpectedToken(symbol: number): boolean;
|
|
332
|
+
get isMatchedEOF(): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Computes the set of input symbols which could follow the current parser
|
|
335
|
+
* state and context, as given by {@link #getState} and {@link #getContext},
|
|
336
|
+
* respectively.
|
|
337
|
+
*
|
|
338
|
+
* @see ATN#getExpectedTokens(int, RuleContext)
|
|
339
|
+
*/
|
|
340
|
+
getExpectedTokens(): IntervalSet;
|
|
341
|
+
getExpectedTokensWithinCurrentRule(): IntervalSet;
|
|
342
|
+
/** Get a rule's index (i.e., `RULE_ruleName` field) or -1 if not found. */
|
|
343
|
+
getRuleIndex(ruleName: string): number;
|
|
344
|
+
get ruleContext(): ParserRuleContext;
|
|
345
|
+
/** Return List<String> of the rule names in your parser instance
|
|
346
|
+
* leading up to a call to the current rule. You could override if
|
|
347
|
+
* you want more details such as the file/line info of where
|
|
348
|
+
* in the ATN a rule is invoked.
|
|
349
|
+
*
|
|
350
|
+
* This is very useful for error messages.
|
|
351
|
+
*/
|
|
352
|
+
getRuleInvocationStack(ctx?: RuleContext): string[];
|
|
353
|
+
/** For debugging and other purposes. */
|
|
354
|
+
getDFAStrings(): string[];
|
|
355
|
+
/** For debugging and other purposes. */
|
|
356
|
+
dumpDFA(): void;
|
|
357
|
+
get sourceName(): string;
|
|
358
|
+
get parseInfo(): Promise<ParseInfo | undefined>;
|
|
359
|
+
/**
|
|
360
|
+
* @since 4.3
|
|
361
|
+
*/
|
|
362
|
+
setProfile(profile: boolean): Promise<void>;
|
|
363
|
+
/** During a parse is sometimes useful to listen in on the rule entry and exit
|
|
364
|
+
* events as well as token matches. This is for quick and dirty debugging.
|
|
365
|
+
*/
|
|
366
|
+
set isTrace(trace: boolean);
|
|
367
|
+
/**
|
|
368
|
+
* Gets whether a {@link TraceListener} is registered as a parse listener
|
|
369
|
+
* for the parser.
|
|
370
|
+
*/
|
|
371
|
+
get isTrace(): boolean;
|
|
372
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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 { ATNConfigSet } from "./atn/ATNConfigSet";
|
|
7
|
+
import { BitSet } from "./misc/BitSet";
|
|
8
|
+
import { DFA } from "./dfa/DFA";
|
|
9
|
+
import { Parser } from "./Parser";
|
|
10
|
+
import { SimulatorState } from "./atn/SimulatorState";
|
|
11
|
+
import { Token } from "./Token";
|
|
12
|
+
/** How to emit recognition errors for parsers.
|
|
13
|
+
*/
|
|
14
|
+
export interface ParserErrorListener extends ANTLRErrorListener<Token> {
|
|
15
|
+
/**
|
|
16
|
+
* This method is called by the parser when a full-context prediction
|
|
17
|
+
* results in an ambiguity.
|
|
18
|
+
*
|
|
19
|
+
* Each full-context prediction which does not result in a syntax error
|
|
20
|
+
* will call either {@link #reportContextSensitivity} or
|
|
21
|
+
* {@link #reportAmbiguity}.
|
|
22
|
+
*
|
|
23
|
+
* When `ambigAlts` is not `undefined`, it contains the set of potentially
|
|
24
|
+
* viable alternatives identified by the prediction algorithm. When
|
|
25
|
+
* `ambigAlts` is `undefined`, use
|
|
26
|
+
* {@link ATNConfigSet#getRepresentedAlternatives} to obtain the represented
|
|
27
|
+
* alternatives from the `configs` argument.
|
|
28
|
+
*
|
|
29
|
+
* When `exact` is `true`, *all* of the potentially
|
|
30
|
+
* viable alternatives are truly viable, i.e. this is reporting an exact
|
|
31
|
+
* ambiguity. When `exact` is `false`, *at least two* of
|
|
32
|
+
* the potentially viable alternatives are viable for the current input, but
|
|
33
|
+
* the prediction algorithm terminated as soon as it determined that at
|
|
34
|
+
* least the *minimum* potentially viable alternative is truly
|
|
35
|
+
* viable.
|
|
36
|
+
*
|
|
37
|
+
* When the {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} prediction
|
|
38
|
+
* mode is used, the parser is required to identify exact ambiguities so
|
|
39
|
+
* `exact` will always be `true`.
|
|
40
|
+
*
|
|
41
|
+
* @param recognizer the parser instance
|
|
42
|
+
* @param dfa the DFA for the current decision
|
|
43
|
+
* @param startIndex the input index where the decision started
|
|
44
|
+
* @param stopIndex the input input where the ambiguity was identified
|
|
45
|
+
* @param exact `true` if the ambiguity is exactly known, otherwise
|
|
46
|
+
* `false`. This is always `true` when
|
|
47
|
+
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} is used.
|
|
48
|
+
* @param ambigAlts the potentially ambiguous alternatives, or `undefined`
|
|
49
|
+
* to indicate that the potentially ambiguous alternatives are the complete
|
|
50
|
+
* set of represented alternatives in `configs`
|
|
51
|
+
* @param configs the ATN configuration set where the ambiguity was
|
|
52
|
+
* identified
|
|
53
|
+
*/
|
|
54
|
+
reportAmbiguity?: (recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, exact: boolean, ambigAlts: BitSet | undefined, configs: ATNConfigSet) => void;
|
|
55
|
+
/**
|
|
56
|
+
* This method is called when an SLL conflict occurs and the parser is about
|
|
57
|
+
* to use the full context information to make an LL decision.
|
|
58
|
+
*
|
|
59
|
+
* If one or more configurations in `configs` contains a semantic
|
|
60
|
+
* predicate, the predicates are evaluated before this method is called. The
|
|
61
|
+
* subset of alternatives which are still viable after predicates are
|
|
62
|
+
* evaluated is reported in `conflictingAlts`.
|
|
63
|
+
*
|
|
64
|
+
* @param recognizer the parser instance
|
|
65
|
+
* @param dfa the DFA for the current decision
|
|
66
|
+
* @param startIndex the input index where the decision started
|
|
67
|
+
* @param stopIndex the input index where the SLL conflict occurred
|
|
68
|
+
* @param conflictingAlts The specific conflicting alternatives. If this is
|
|
69
|
+
* `undefined`, the conflicting alternatives are all alternatives
|
|
70
|
+
* represented in `configs`.
|
|
71
|
+
* @param conflictState the simulator state when the SLL conflict was
|
|
72
|
+
* detected
|
|
73
|
+
*/
|
|
74
|
+
reportAttemptingFullContext?: (recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, conflictingAlts: BitSet | undefined, conflictState: SimulatorState) => void;
|
|
75
|
+
/**
|
|
76
|
+
* This method is called by the parser when a full-context prediction has a
|
|
77
|
+
* unique result.
|
|
78
|
+
*
|
|
79
|
+
* Each full-context prediction which does not result in a syntax error
|
|
80
|
+
* will call either {@link #reportContextSensitivity} or
|
|
81
|
+
* {@link #reportAmbiguity}.
|
|
82
|
+
*
|
|
83
|
+
* For prediction implementations that only evaluate full-context
|
|
84
|
+
* predictions when an SLL conflict is found (including the default
|
|
85
|
+
* {@link ParserATNSimulator} implementation), this method reports cases
|
|
86
|
+
* where SLL conflicts were resolved to unique full-context predictions,
|
|
87
|
+
* i.e. the decision was context-sensitive. This report does not necessarily
|
|
88
|
+
* indicate a problem, and it may appear even in completely unambiguous
|
|
89
|
+
* grammars.
|
|
90
|
+
*
|
|
91
|
+
* `configs` may have more than one represented alternative if the
|
|
92
|
+
* full-context prediction algorithm does not evaluate predicates before
|
|
93
|
+
* beginning the full-context prediction. In all cases, the final prediction
|
|
94
|
+
* is passed as the `prediction` argument.
|
|
95
|
+
*
|
|
96
|
+
* Note that the definition of "context sensitivity" in this method
|
|
97
|
+
* differs from the concept in {@link DecisionInfo#contextSensitivities}.
|
|
98
|
+
* This method reports all instances where an SLL conflict occurred but LL
|
|
99
|
+
* parsing produced a unique result, whether or not that unique result
|
|
100
|
+
* matches the minimum alternative in the SLL conflicting set.
|
|
101
|
+
*
|
|
102
|
+
* @param recognizer the parser instance
|
|
103
|
+
* @param dfa the DFA for the current decision
|
|
104
|
+
* @param startIndex the input index where the decision started
|
|
105
|
+
* @param stopIndex the input index where the context sensitivity was
|
|
106
|
+
* finally determined
|
|
107
|
+
* @param prediction the unambiguous result of the full-context prediction
|
|
108
|
+
* @param acceptState the simulator state when the unambiguous prediction
|
|
109
|
+
* was determined
|
|
110
|
+
*/
|
|
111
|
+
reportContextSensitivity?: (recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, prediction: number, acceptState: SimulatorState) => void;
|
|
112
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
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 { ATN } from "./atn/ATN";
|
|
6
|
+
import { ATNState } from "./atn/ATNState";
|
|
7
|
+
import { BitSet } from "./misc/BitSet";
|
|
8
|
+
import { DecisionState } from "./atn/DecisionState";
|
|
9
|
+
import { InterpreterRuleContext } from "./InterpreterRuleContext";
|
|
10
|
+
import { Parser } from "./Parser";
|
|
11
|
+
import { ParserRuleContext } from "./ParserRuleContext";
|
|
12
|
+
import { RecognitionException } from "./RecognitionException";
|
|
13
|
+
import { Token } from "./Token";
|
|
14
|
+
import { TokenStream } from "./TokenStream";
|
|
15
|
+
import { Vocabulary } from "./Vocabulary";
|
|
16
|
+
/** A parser simulator that mimics what ANTLR's generated
|
|
17
|
+
* parser code does. A ParserATNSimulator is used to make
|
|
18
|
+
* predictions via adaptivePredict but this class moves a pointer through the
|
|
19
|
+
* ATN to simulate parsing. ParserATNSimulator just
|
|
20
|
+
* makes us efficient rather than having to backtrack, for example.
|
|
21
|
+
*
|
|
22
|
+
* This properly creates parse trees even for left recursive rules.
|
|
23
|
+
*
|
|
24
|
+
* We rely on the left recursive rule invocation and special predicate
|
|
25
|
+
* transitions to make left recursive rules work.
|
|
26
|
+
*
|
|
27
|
+
* See TestParserInterpreter for examples.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ParserInterpreter extends Parser {
|
|
30
|
+
protected _grammarFileName: string;
|
|
31
|
+
protected _atn: ATN;
|
|
32
|
+
/** This identifies StarLoopEntryState's that begin the (...)*
|
|
33
|
+
* precedence loops of left recursive rules.
|
|
34
|
+
*/
|
|
35
|
+
protected pushRecursionContextStates: BitSet;
|
|
36
|
+
protected _ruleNames: string[];
|
|
37
|
+
private _vocabulary;
|
|
38
|
+
/** This stack corresponds to the _parentctx, _parentState pair of locals
|
|
39
|
+
* that would exist on call stack frames with a recursive descent parser;
|
|
40
|
+
* in the generated function for a left-recursive rule you'd see:
|
|
41
|
+
*
|
|
42
|
+
* private EContext e(int _p) {
|
|
43
|
+
* ParserRuleContext _parentctx = _ctx; // Pair.a
|
|
44
|
+
* int _parentState = state; // Pair.b
|
|
45
|
+
* ...
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* Those values are used to create new recursive rule invocation contexts
|
|
49
|
+
* associated with left operand of an alt like "expr '*' expr".
|
|
50
|
+
*/
|
|
51
|
+
protected readonly _parentContextStack: Array<[ParserRuleContext, number]>;
|
|
52
|
+
/** We need a map from (decision,inputIndex)->forced alt for computing ambiguous
|
|
53
|
+
* parse trees. For now, we allow exactly one override.
|
|
54
|
+
*/
|
|
55
|
+
protected overrideDecision: number;
|
|
56
|
+
protected overrideDecisionInputIndex: number;
|
|
57
|
+
protected overrideDecisionAlt: number;
|
|
58
|
+
protected overrideDecisionReached: boolean;
|
|
59
|
+
/** What is the current context when we override a decisions? This tells
|
|
60
|
+
* us what the root of the parse tree is when using override
|
|
61
|
+
* for an ambiguity/lookahead check.
|
|
62
|
+
*/
|
|
63
|
+
protected _overrideDecisionRoot?: InterpreterRuleContext;
|
|
64
|
+
protected _rootContext: InterpreterRuleContext;
|
|
65
|
+
/** A copy constructor that creates a new parser interpreter by reusing
|
|
66
|
+
* the fields of a previous interpreter.
|
|
67
|
+
*
|
|
68
|
+
* @param old The interpreter to copy
|
|
69
|
+
*
|
|
70
|
+
* @since 4.5
|
|
71
|
+
*/
|
|
72
|
+
constructor(/*@NotNull*/ old: ParserInterpreter);
|
|
73
|
+
constructor(grammarFileName: string, /*@NotNull*/ vocabulary: Vocabulary, ruleNames: string[], atn: ATN, input: TokenStream);
|
|
74
|
+
reset(resetInput?: boolean): void;
|
|
75
|
+
get atn(): ATN;
|
|
76
|
+
get vocabulary(): Vocabulary;
|
|
77
|
+
get ruleNames(): string[];
|
|
78
|
+
get grammarFileName(): string;
|
|
79
|
+
/** Begin parsing at startRuleIndex */
|
|
80
|
+
parse(startRuleIndex: number): ParserRuleContext;
|
|
81
|
+
enterRecursionRule(localctx: ParserRuleContext, state: number, ruleIndex: number, precedence: number): void;
|
|
82
|
+
protected get atnState(): ATNState;
|
|
83
|
+
protected visitState(p: ATNState): void;
|
|
84
|
+
/** Method visitDecisionState() is called when the interpreter reaches
|
|
85
|
+
* a decision state (instance of DecisionState). It gives an opportunity
|
|
86
|
+
* for subclasses to track interesting things.
|
|
87
|
+
*/
|
|
88
|
+
protected visitDecisionState(p: DecisionState): number;
|
|
89
|
+
/** Provide simple "factory" for InterpreterRuleContext's.
|
|
90
|
+
* @since 4.5.1
|
|
91
|
+
*/
|
|
92
|
+
protected createInterpreterRuleContext(parent: ParserRuleContext | undefined, invokingStateNumber: number, ruleIndex: number): InterpreterRuleContext;
|
|
93
|
+
protected visitRuleStopState(p: ATNState): void;
|
|
94
|
+
/** Override this parser interpreters normal decision-making process
|
|
95
|
+
* at a particular decision and input token index. Instead of
|
|
96
|
+
* allowing the adaptive prediction mechanism to choose the
|
|
97
|
+
* first alternative within a block that leads to a successful parse,
|
|
98
|
+
* force it to take the alternative, 1..n for n alternatives.
|
|
99
|
+
*
|
|
100
|
+
* As an implementation limitation right now, you can only specify one
|
|
101
|
+
* override. This is sufficient to allow construction of different
|
|
102
|
+
* parse trees for ambiguous input. It means re-parsing the entire input
|
|
103
|
+
* in general because you're never sure where an ambiguous sequence would
|
|
104
|
+
* live in the various parse trees. For example, in one interpretation,
|
|
105
|
+
* an ambiguous input sequence would be matched completely in expression
|
|
106
|
+
* but in another it could match all the way back to the root.
|
|
107
|
+
*
|
|
108
|
+
* s : e '!'? ;
|
|
109
|
+
* e : ID
|
|
110
|
+
* | ID '!'
|
|
111
|
+
* ;
|
|
112
|
+
*
|
|
113
|
+
* Here, x! can be matched as (s (e ID) !) or (s (e ID !)). In the first
|
|
114
|
+
* case, the ambiguous sequence is fully contained only by the root.
|
|
115
|
+
* In the second case, the ambiguous sequences fully contained within just
|
|
116
|
+
* e, as in: (e ID !).
|
|
117
|
+
*
|
|
118
|
+
* Rather than trying to optimize this and make
|
|
119
|
+
* some intelligent decisions for optimization purposes, I settled on
|
|
120
|
+
* just re-parsing the whole input and then using
|
|
121
|
+
* {link Trees#getRootOfSubtreeEnclosingRegion} to find the minimal
|
|
122
|
+
* subtree that contains the ambiguous sequence. I originally tried to
|
|
123
|
+
* record the call stack at the point the parser detected and ambiguity but
|
|
124
|
+
* left recursive rules create a parse tree stack that does not reflect
|
|
125
|
+
* the actual call stack. That impedance mismatch was enough to make
|
|
126
|
+
* it it challenging to restart the parser at a deeply nested rule
|
|
127
|
+
* invocation.
|
|
128
|
+
*
|
|
129
|
+
* Only parser interpreters can override decisions so as to avoid inserting
|
|
130
|
+
* override checking code in the critical ALL(*) prediction execution path.
|
|
131
|
+
*
|
|
132
|
+
* @since 4.5
|
|
133
|
+
*/
|
|
134
|
+
addDecisionOverride(decision: number, tokenIndex: number, forcedAlt: number): void;
|
|
135
|
+
get overrideDecisionRoot(): InterpreterRuleContext | undefined;
|
|
136
|
+
/** Rely on the error handler for this parser but, if no tokens are consumed
|
|
137
|
+
* to recover, add an error node. Otherwise, nothing is seen in the parse
|
|
138
|
+
* tree.
|
|
139
|
+
*/
|
|
140
|
+
protected recover(e: RecognitionException): void;
|
|
141
|
+
protected recoverInline(): Token;
|
|
142
|
+
/** Return the root of the parse, which can be useful if the parser
|
|
143
|
+
* bails out. You still can access the top node. Note that,
|
|
144
|
+
* because of the way left recursive rules add children, it's possible
|
|
145
|
+
* that the root will not have any children if the start rule immediately
|
|
146
|
+
* called and left recursive rule that fails.
|
|
147
|
+
*
|
|
148
|
+
* @since 4.5.1
|
|
149
|
+
*/
|
|
150
|
+
get rootContext(): InterpreterRuleContext;
|
|
151
|
+
}
|