@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
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
/** How to emit recognition errors. */
|
|
6
|
+
import { Recognizer } from "./Recognizer";
|
|
7
|
+
import { RecognitionException } from "./RecognitionException";
|
|
8
|
+
export interface ANTLRErrorListener<TSymbol> {
|
|
9
|
+
/**
|
|
10
|
+
* Upon syntax error, notify any interested parties. This is not how to
|
|
11
|
+
* recover from errors or compute error messages. {@link ANTLRErrorStrategy}
|
|
12
|
+
* specifies how to recover from syntax errors and how to compute error
|
|
13
|
+
* messages. This listener's job is simply to emit a computed message,
|
|
14
|
+
* though it has enough information to create its own message in many cases.
|
|
15
|
+
*
|
|
16
|
+
* The {@link RecognitionException} is non-`undefined` for all syntax errors except
|
|
17
|
+
* when we discover mismatched token errors that we can recover from
|
|
18
|
+
* in-line, without returning from the surrounding rule (via the single
|
|
19
|
+
* token insertion and deletion mechanism).
|
|
20
|
+
*
|
|
21
|
+
* @param recognizer
|
|
22
|
+
* What parser got the error. From this
|
|
23
|
+
* object, you can access the context as well
|
|
24
|
+
* as the input stream.
|
|
25
|
+
* @param offendingSymbol
|
|
26
|
+
* The offending token in the input token
|
|
27
|
+
* stream, unless recognizer is a lexer (then it's `undefined`). If
|
|
28
|
+
* no viable alternative error, `e` has token at which we
|
|
29
|
+
* started production for the decision.
|
|
30
|
+
* @param line
|
|
31
|
+
* The line number in the input where the error occurred.
|
|
32
|
+
* @param charPositionInLine
|
|
33
|
+
* The character position within that line where the error occurred.
|
|
34
|
+
* @param msg
|
|
35
|
+
* The message to emit.
|
|
36
|
+
* @param e
|
|
37
|
+
* The exception generated by the parser that led to
|
|
38
|
+
* the reporting of an error. It is `undefined` in the case where
|
|
39
|
+
* the parser was able to recover in line without exiting the
|
|
40
|
+
* surrounding rule.
|
|
41
|
+
*/
|
|
42
|
+
syntaxError?: <T extends TSymbol>(recognizer: Recognizer<T, any>, offendingSymbol: T | undefined, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined) => void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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 { Parser } from "./Parser";
|
|
6
|
+
import { Token } from "./Token";
|
|
7
|
+
import { RecognitionException } from "./RecognitionException";
|
|
8
|
+
/**
|
|
9
|
+
* The interface for defining strategies to deal with syntax errors encountered
|
|
10
|
+
* during a parse by ANTLR-generated parsers. We distinguish between three
|
|
11
|
+
* different kinds of errors:
|
|
12
|
+
*
|
|
13
|
+
* * The parser could not figure out which path to take in the ATN (none of
|
|
14
|
+
* the available alternatives could possibly match)
|
|
15
|
+
* * The current input does not match what we were looking for
|
|
16
|
+
* * A predicate evaluated to false
|
|
17
|
+
*
|
|
18
|
+
* Implementations of this interface report syntax errors by calling
|
|
19
|
+
* {@link Parser#notifyErrorListeners}.
|
|
20
|
+
*
|
|
21
|
+
* TODO: what to do about lexers
|
|
22
|
+
*/
|
|
23
|
+
export interface ANTLRErrorStrategy {
|
|
24
|
+
/**
|
|
25
|
+
* Reset the error handler state for the specified `recognizer`.
|
|
26
|
+
* @param recognizer the parser instance
|
|
27
|
+
*/
|
|
28
|
+
reset(/*@NotNull*/ recognizer: Parser): void;
|
|
29
|
+
/**
|
|
30
|
+
* This method is called when an unexpected symbol is encountered during an
|
|
31
|
+
* inline match operation, such as {@link Parser#match}. If the error
|
|
32
|
+
* strategy successfully recovers from the match failure, this method
|
|
33
|
+
* returns the {@link Token} instance which should be treated as the
|
|
34
|
+
* successful result of the match.
|
|
35
|
+
*
|
|
36
|
+
* This method handles the consumption of any tokens - the caller should
|
|
37
|
+
* *not* call {@link Parser#consume} after a successful recovery.
|
|
38
|
+
*
|
|
39
|
+
* Note that the calling code will not report an error if this method
|
|
40
|
+
* returns successfully. The error strategy implementation is responsible
|
|
41
|
+
* for calling {@link Parser#notifyErrorListeners} as appropriate.
|
|
42
|
+
*
|
|
43
|
+
* @param recognizer the parser instance
|
|
44
|
+
* @ if the error strategy was not able to
|
|
45
|
+
* recover from the unexpected input symbol
|
|
46
|
+
*/
|
|
47
|
+
recoverInline(/*@NotNull*/ recognizer: Parser): Token;
|
|
48
|
+
/**
|
|
49
|
+
* This method is called to recover from exception `e`. This method is
|
|
50
|
+
* called after {@link #reportError} by the default exception handler
|
|
51
|
+
* generated for a rule method.
|
|
52
|
+
*
|
|
53
|
+
* @see #reportError
|
|
54
|
+
*
|
|
55
|
+
* @param recognizer the parser instance
|
|
56
|
+
* @param e the recognition exception to recover from
|
|
57
|
+
* @ if the error strategy could not recover from
|
|
58
|
+
* the recognition exception
|
|
59
|
+
*/
|
|
60
|
+
recover(/*@NotNull*/ recognizer: Parser, /*@NotNull*/ e: RecognitionException): void;
|
|
61
|
+
/**
|
|
62
|
+
* This method provides the error handler with an opportunity to handle
|
|
63
|
+
* syntactic or semantic errors in the input stream before they result in a
|
|
64
|
+
* {@link RecognitionException}.
|
|
65
|
+
*
|
|
66
|
+
* The generated code currently contains calls to {@link #sync} after
|
|
67
|
+
* entering the decision state of a closure block (`(...)*` or
|
|
68
|
+
* `(...)+`).
|
|
69
|
+
*
|
|
70
|
+
* For an implementation based on Jim Idle's "magic sync" mechanism, see
|
|
71
|
+
* {@link DefaultErrorStrategy#sync}.
|
|
72
|
+
*
|
|
73
|
+
* @see DefaultErrorStrategy#sync
|
|
74
|
+
*
|
|
75
|
+
* @param recognizer the parser instance
|
|
76
|
+
* @ if an error is detected by the error
|
|
77
|
+
* strategy but cannot be automatically recovered at the current state in
|
|
78
|
+
* the parsing process
|
|
79
|
+
*/
|
|
80
|
+
sync(/*@NotNull*/ recognizer: Parser): void;
|
|
81
|
+
/**
|
|
82
|
+
* Tests whether or not `recognizer` is in the process of recovering
|
|
83
|
+
* from an error. In error recovery mode, {@link Parser#consume} adds
|
|
84
|
+
* symbols to the parse tree by calling
|
|
85
|
+
* {@link Parser#createErrorNode(ParserRuleContext, Token)} then
|
|
86
|
+
* {@link ParserRuleContext#addErrorNode(ErrorNode)} instead of
|
|
87
|
+
* {@link Parser#createTerminalNode(ParserRuleContext, Token)}.
|
|
88
|
+
*
|
|
89
|
+
* @param recognizer the parser instance
|
|
90
|
+
* @returns `true` if the parser is currently recovering from a parse
|
|
91
|
+
* error, otherwise `false`
|
|
92
|
+
*/
|
|
93
|
+
inErrorRecoveryMode(/*@NotNull*/ recognizer: Parser): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* This method is called by when the parser successfully matches an input
|
|
96
|
+
* symbol.
|
|
97
|
+
*
|
|
98
|
+
* @param recognizer the parser instance
|
|
99
|
+
*/
|
|
100
|
+
reportMatch(/*@NotNull*/ recognizer: Parser): void;
|
|
101
|
+
/**
|
|
102
|
+
* Report any kind of {@link RecognitionException}. This method is called by
|
|
103
|
+
* the default exception handler generated for a rule method.
|
|
104
|
+
*
|
|
105
|
+
* @param recognizer the parser instance
|
|
106
|
+
* @param e the recognition exception to report
|
|
107
|
+
*/
|
|
108
|
+
reportError(recognizer: Parser, e: RecognitionException): void;
|
|
109
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { Interval } from "./misc/Interval";
|
|
7
|
+
/**
|
|
8
|
+
* Vacuum all input from a {@link Reader}/{@link InputStream} and then treat it
|
|
9
|
+
* like a `char[]` buffer. Can also pass in a {@link String} or
|
|
10
|
+
* `char[]` to use.
|
|
11
|
+
*
|
|
12
|
+
* If you need encoding, pass in stream/reader with correct encoding.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated as of 4.7, please use `CharStreams` interface.
|
|
15
|
+
*/
|
|
16
|
+
export declare class ANTLRInputStream implements CharStream {
|
|
17
|
+
/** The data being scanned */
|
|
18
|
+
protected data: string;
|
|
19
|
+
/** How many characters are actually in the buffer */
|
|
20
|
+
protected n: number;
|
|
21
|
+
/** 0..n-1 index into string of next char */
|
|
22
|
+
protected p: number;
|
|
23
|
+
/** What is name or source of this char stream? */
|
|
24
|
+
name?: string;
|
|
25
|
+
/** Copy data in string to a local char array */
|
|
26
|
+
constructor(input: string);
|
|
27
|
+
/** Reset the stream so that it's in the same state it was
|
|
28
|
+
* when the object was created *except* the data array is not
|
|
29
|
+
* touched.
|
|
30
|
+
*/
|
|
31
|
+
reset(): void;
|
|
32
|
+
consume(): void;
|
|
33
|
+
LA(i: number): number;
|
|
34
|
+
LT(i: number): number;
|
|
35
|
+
/** Return the current input symbol index 0..n where n indicates the
|
|
36
|
+
* last symbol has been read. The index is the index of char to
|
|
37
|
+
* be returned from LA(1).
|
|
38
|
+
*/
|
|
39
|
+
get index(): number;
|
|
40
|
+
get size(): number;
|
|
41
|
+
/** mark/release do nothing; we have entire buffer */
|
|
42
|
+
mark(): number;
|
|
43
|
+
release(marker: number): void;
|
|
44
|
+
/** consume() ahead until p==index; can't just set p=index as we must
|
|
45
|
+
* update line and charPositionInLine. If we seek backwards, just set p
|
|
46
|
+
*/
|
|
47
|
+
seek(index: number): void;
|
|
48
|
+
getText(interval: Interval): string;
|
|
49
|
+
get sourceName(): string;
|
|
50
|
+
toString(): string;
|
|
51
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { DefaultErrorStrategy } from "./DefaultErrorStrategy";
|
|
6
|
+
import { Parser } from "./Parser";
|
|
7
|
+
import { RecognitionException } from "./RecognitionException";
|
|
8
|
+
import { Token } from "./Token";
|
|
9
|
+
/**
|
|
10
|
+
* This implementation of {@link ANTLRErrorStrategy} responds to syntax errors
|
|
11
|
+
* by immediately canceling the parse operation with a
|
|
12
|
+
* {@link ParseCancellationException}. The implementation ensures that the
|
|
13
|
+
* {@link ParserRuleContext#exception} field is set for all parse tree nodes
|
|
14
|
+
* that were not completed prior to encountering the error.
|
|
15
|
+
*
|
|
16
|
+
* This error strategy is useful in the following scenarios.
|
|
17
|
+
*
|
|
18
|
+
* * **Two-stage parsing:** This error strategy allows the first
|
|
19
|
+
* stage of two-stage parsing to immediately terminate if an error is
|
|
20
|
+
* encountered, and immediately fall back to the second stage. In addition to
|
|
21
|
+
* avoiding wasted work by attempting to recover from errors here, the empty
|
|
22
|
+
* implementation of {@link BailErrorStrategy#sync} improves the performance of
|
|
23
|
+
* the first stage.
|
|
24
|
+
* * **Silent validation:** When syntax errors are not being
|
|
25
|
+
* reported or logged, and the parse result is simply ignored if errors occur,
|
|
26
|
+
* the {@link BailErrorStrategy} avoids wasting work on recovering from errors
|
|
27
|
+
* when the result will be ignored either way.
|
|
28
|
+
*
|
|
29
|
+
* ```
|
|
30
|
+
* myparser.errorHandler = new BailErrorStrategy();
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see Parser.errorHandler
|
|
34
|
+
*/
|
|
35
|
+
export declare class BailErrorStrategy extends DefaultErrorStrategy {
|
|
36
|
+
/** Instead of recovering from exception `e`, re-throw it wrapped
|
|
37
|
+
* in a {@link ParseCancellationException} so it is not caught by the
|
|
38
|
+
* rule function catches. Use {@link Exception#getCause()} to get the
|
|
39
|
+
* original {@link RecognitionException}.
|
|
40
|
+
*/
|
|
41
|
+
recover(recognizer: Parser, e: RecognitionException): void;
|
|
42
|
+
/** Make sure we don't attempt to recover inline; if the parser
|
|
43
|
+
* successfully recovers, it won't throw an exception.
|
|
44
|
+
*/
|
|
45
|
+
recoverInline(recognizer: Parser): Token;
|
|
46
|
+
/** Make sure we don't attempt to recover from problems in subrules. */
|
|
47
|
+
sync(recognizer: Parser): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 { Interval } from "./misc/Interval";
|
|
6
|
+
import { RuleContext } from "./RuleContext";
|
|
7
|
+
import { Token } from "./Token";
|
|
8
|
+
import { TokenSource } from "./TokenSource";
|
|
9
|
+
import { TokenStream } from "./TokenStream";
|
|
10
|
+
/**
|
|
11
|
+
* This implementation of {@link TokenStream} loads tokens from a
|
|
12
|
+
* {@link TokenSource} on-demand, and places the tokens in a buffer to provide
|
|
13
|
+
* access to any previous token by index.
|
|
14
|
+
*
|
|
15
|
+
* This token stream ignores the value of {@link Token#getChannel}. If your
|
|
16
|
+
* parser requires the token stream filter tokens to only those on a particular
|
|
17
|
+
* channel, such as {@link Token#DEFAULT_CHANNEL} or
|
|
18
|
+
* {@link Token#HIDDEN_CHANNEL}, use a filtering token stream such a
|
|
19
|
+
* {@link CommonTokenStream}.
|
|
20
|
+
*/
|
|
21
|
+
export declare class BufferedTokenStream implements TokenStream {
|
|
22
|
+
/**
|
|
23
|
+
* The {@link TokenSource} from which tokens for this stream are fetched.
|
|
24
|
+
*/
|
|
25
|
+
private _tokenSource;
|
|
26
|
+
/**
|
|
27
|
+
* A collection of all tokens fetched from the token source. The list is
|
|
28
|
+
* considered a complete view of the input once {@link #fetchedEOF} is set
|
|
29
|
+
* to `true`.
|
|
30
|
+
*/
|
|
31
|
+
protected tokens: Token[];
|
|
32
|
+
/**
|
|
33
|
+
* The index into {@link #tokens} of the current token (next token to
|
|
34
|
+
* {@link #consume}). {@link #tokens}`[`{@link #p}`]` should be
|
|
35
|
+
* {@link #LT LT(1)}.
|
|
36
|
+
*
|
|
37
|
+
* This field is set to -1 when the stream is first constructed or when
|
|
38
|
+
* {@link #setTokenSource} is called, indicating that the first token has
|
|
39
|
+
* not yet been fetched from the token source. For additional information,
|
|
40
|
+
* see the documentation of {@link IntStream} for a description of
|
|
41
|
+
* Initializing Methods.
|
|
42
|
+
*/
|
|
43
|
+
protected p: number;
|
|
44
|
+
/**
|
|
45
|
+
* Indicates whether the {@link Token#EOF} token has been fetched from
|
|
46
|
+
* {@link #tokenSource} and added to {@link #tokens}. This field improves
|
|
47
|
+
* performance for the following cases:
|
|
48
|
+
*
|
|
49
|
+
* * {@link #consume}: The lookahead check in {@link #consume} to prevent
|
|
50
|
+
* consuming the EOF symbol is optimized by checking the values of
|
|
51
|
+
* {@link #fetchedEOF} and {@link #p} instead of calling {@link #LA}.
|
|
52
|
+
* * {@link #fetch}: The check to prevent adding multiple EOF symbols into
|
|
53
|
+
* {@link #tokens} is trivial with this field.
|
|
54
|
+
*/
|
|
55
|
+
protected fetchedEOF: boolean;
|
|
56
|
+
constructor(tokenSource: TokenSource);
|
|
57
|
+
get tokenSource(): TokenSource;
|
|
58
|
+
/** Reset this token stream by setting its token source. */
|
|
59
|
+
set tokenSource(tokenSource: TokenSource);
|
|
60
|
+
get index(): number;
|
|
61
|
+
mark(): number;
|
|
62
|
+
release(marker: number): void;
|
|
63
|
+
seek(index: number): void;
|
|
64
|
+
get size(): number;
|
|
65
|
+
consume(): void;
|
|
66
|
+
/** Make sure index `i` in tokens has a token.
|
|
67
|
+
*
|
|
68
|
+
* @returns `true` if a token is located at index `i`, otherwise
|
|
69
|
+
* `false`.
|
|
70
|
+
* @see #get(int i)
|
|
71
|
+
*/
|
|
72
|
+
protected sync(i: number): boolean;
|
|
73
|
+
/** Add `n` elements to buffer.
|
|
74
|
+
*
|
|
75
|
+
* @returns The actual number of elements added to the buffer.
|
|
76
|
+
*/
|
|
77
|
+
protected fetch(n: number): number;
|
|
78
|
+
get(i: number): Token;
|
|
79
|
+
/** Get all tokens from start..stop inclusively. */
|
|
80
|
+
getRange(start: number, stop: number): Token[];
|
|
81
|
+
LA(i: number): number;
|
|
82
|
+
protected tryLB(k: number): Token | undefined;
|
|
83
|
+
LT(k: number): Token;
|
|
84
|
+
tryLT(k: number): Token | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Allowed derived classes to modify the behavior of operations which change
|
|
87
|
+
* the current stream position by adjusting the target token index of a seek
|
|
88
|
+
* operation. The default implementation simply returns `i`. If an
|
|
89
|
+
* exception is thrown in this method, the current stream index should not be
|
|
90
|
+
* changed.
|
|
91
|
+
*
|
|
92
|
+
* For example, {@link CommonTokenStream} overrides this method to ensure that
|
|
93
|
+
* the seek target is always an on-channel token.
|
|
94
|
+
*
|
|
95
|
+
* @param i The target token index.
|
|
96
|
+
* @returns The adjusted target token index.
|
|
97
|
+
*/
|
|
98
|
+
protected adjustSeekIndex(i: number): number;
|
|
99
|
+
protected lazyInit(): void;
|
|
100
|
+
protected setup(): void;
|
|
101
|
+
getTokens(): Token[];
|
|
102
|
+
getTokens(start: number, stop: number): Token[];
|
|
103
|
+
getTokens(start: number, stop: number, types: Set<number>): Token[];
|
|
104
|
+
getTokens(start: number, stop: number, ttype: number): Token[];
|
|
105
|
+
/**
|
|
106
|
+
* Given a starting index, return the index of the next token on channel.
|
|
107
|
+
* Return `i` if `tokens[i]` is on channel. Return the index of
|
|
108
|
+
* the EOF token if there are no tokens on channel between `i` and
|
|
109
|
+
* EOF.
|
|
110
|
+
*/
|
|
111
|
+
protected nextTokenOnChannel(i: number, channel: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Given a starting index, return the index of the previous token on
|
|
114
|
+
* channel. Return `i` if `tokens[i]` is on channel. Return -1
|
|
115
|
+
* if there are no tokens on channel between `i` and 0.
|
|
116
|
+
*
|
|
117
|
+
* If `i` specifies an index at or after the EOF token, the EOF token
|
|
118
|
+
* index is returned. This is due to the fact that the EOF token is treated
|
|
119
|
+
* as though it were on every channel.
|
|
120
|
+
*/
|
|
121
|
+
protected previousTokenOnChannel(i: number, channel: number): number;
|
|
122
|
+
/** Collect all tokens on specified channel to the right of
|
|
123
|
+
* the current token up until we see a token on {@link Lexer#DEFAULT_TOKEN_CHANNEL} or
|
|
124
|
+
* EOF. If `channel` is `-1`, find any non default channel token.
|
|
125
|
+
*/
|
|
126
|
+
getHiddenTokensToRight(tokenIndex: number, channel?: number): Token[];
|
|
127
|
+
/** Collect all tokens on specified channel to the left of
|
|
128
|
+
* the current token up until we see a token on {@link Lexer#DEFAULT_TOKEN_CHANNEL}.
|
|
129
|
+
* If `channel` is `-1`, find any non default channel token.
|
|
130
|
+
*/
|
|
131
|
+
getHiddenTokensToLeft(tokenIndex: number, channel?: number): Token[];
|
|
132
|
+
protected filterForChannel(from: number, to: number, channel: number): Token[];
|
|
133
|
+
get sourceName(): string;
|
|
134
|
+
/** Get the text of all tokens in this buffer. */
|
|
135
|
+
getText(): string;
|
|
136
|
+
getText(interval: Interval): string;
|
|
137
|
+
getText(context: RuleContext): string;
|
|
138
|
+
getTextFromRange(start: any, stop: any): string;
|
|
139
|
+
/** Get all tokens from lexer until EOF. */
|
|
140
|
+
fill(): void;
|
|
141
|
+
private isWritableToken;
|
|
142
|
+
private isToken;
|
|
143
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { Interval } from "./misc/Interval";
|
|
6
|
+
import { IntStream } from "./IntStream";
|
|
7
|
+
/** A source of characters for an ANTLR lexer. */
|
|
8
|
+
export interface CharStream extends IntStream {
|
|
9
|
+
/**
|
|
10
|
+
* This method returns the text for a range of characters within this input
|
|
11
|
+
* stream. This method is guaranteed to not throw an exception if the
|
|
12
|
+
* specified `interval` lies entirely within a marked range. For more
|
|
13
|
+
* information about marked ranges, see {@link IntStream#mark}.
|
|
14
|
+
*
|
|
15
|
+
* @param interval an interval within the stream
|
|
16
|
+
* @returns the text of the specified interval
|
|
17
|
+
*
|
|
18
|
+
* @throws NullPointerException if `interval` is `undefined`
|
|
19
|
+
* @throws IllegalArgumentException if `interval.a < 0`, or if
|
|
20
|
+
* `interval.b < interval.a - 1`, or if `interval.b` lies at or
|
|
21
|
+
* past the end of the stream
|
|
22
|
+
* @throws UnsupportedOperationException if the stream does not support
|
|
23
|
+
* getting the text of the specified interval
|
|
24
|
+
*/
|
|
25
|
+
getText(/*@NotNull*/ interval: Interval): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { CodePointCharStream } from "./CodePointCharStream";
|
|
6
|
+
/** This class represents the primary interface for creating {@link CharStream}s
|
|
7
|
+
* from a variety of sources as of 4.7. The motivation was to support
|
|
8
|
+
* Unicode code points > U+FFFF. {@link ANTLRInputStream} and
|
|
9
|
+
* {@link ANTLRFileStream} are now deprecated in favor of the streams created
|
|
10
|
+
* by this interface.
|
|
11
|
+
*
|
|
12
|
+
* DEPRECATED: {@code new ANTLRFileStream("myinputfile")}
|
|
13
|
+
* NEW: {@code CharStreams.fromFileName("myinputfile")}
|
|
14
|
+
*
|
|
15
|
+
* WARNING: If you use both the deprecated and the new streams, you will see
|
|
16
|
+
* a nontrivial performance degradation. This speed hit is because the
|
|
17
|
+
* {@link Lexer}'s internal code goes from a monomorphic to megamorphic
|
|
18
|
+
* dynamic dispatch to get characters from the input stream. Java's
|
|
19
|
+
* on-the-fly compiler (JIT) is unable to perform the same optimizations
|
|
20
|
+
* so stick with either the old or the new streams, if performance is
|
|
21
|
+
* a primary concern. See the extreme debugging and spelunking
|
|
22
|
+
* needed to identify this issue in our timing rig:
|
|
23
|
+
*
|
|
24
|
+
* https://github.com/antlr/antlr4/pull/1781
|
|
25
|
+
*
|
|
26
|
+
* The ANTLR character streams still buffer all the input when you create
|
|
27
|
+
* the stream, as they have done for ~20 years. If you need unbuffered
|
|
28
|
+
* access, please note that it becomes challenging to create
|
|
29
|
+
* parse trees. The parse tree has to point to tokens which will either
|
|
30
|
+
* point into a stale location in an unbuffered stream or you have to copy
|
|
31
|
+
* the characters out of the buffer into the token. That defeats the purpose
|
|
32
|
+
* of unbuffered input. Per the ANTLR book, unbuffered streams are primarily
|
|
33
|
+
* useful for processing infinite streams *during the parse.*
|
|
34
|
+
*
|
|
35
|
+
* The new streams also use 8-bit buffers when possible so this new
|
|
36
|
+
* interface supports character streams that use half as much memory
|
|
37
|
+
* as the old {@link ANTLRFileStream}, which assumed 16-bit characters.
|
|
38
|
+
*
|
|
39
|
+
* A big shout out to Ben Hamilton (github bhamiltoncx) for his superhuman
|
|
40
|
+
* efforts across all targets to get true Unicode 3.1 support for U+10FFFF.
|
|
41
|
+
*
|
|
42
|
+
* @since 4.7
|
|
43
|
+
*/
|
|
44
|
+
export declare namespace CharStreams {
|
|
45
|
+
/**
|
|
46
|
+
* Creates a {@link CharStream} given a {@link String}.
|
|
47
|
+
*/
|
|
48
|
+
function fromString(s: string): CodePointCharStream;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a {@link CharStream} given a {@link String} and the {@code sourceName}
|
|
51
|
+
* from which it came.
|
|
52
|
+
*/
|
|
53
|
+
function fromString(s: string, sourceName: string): CodePointCharStream;
|
|
54
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Wrapper for `Uint8Array` / `Uint16Array` / `Int32Array`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CodePointBuffer {
|
|
9
|
+
private readonly buffer;
|
|
10
|
+
private _position;
|
|
11
|
+
private _size;
|
|
12
|
+
constructor(buffer: Uint8Array | Uint16Array | Int32Array, size: number);
|
|
13
|
+
static withArray(buffer: Uint8Array | Uint16Array | Int32Array): CodePointBuffer;
|
|
14
|
+
get position(): number;
|
|
15
|
+
set position(newPosition: number);
|
|
16
|
+
get remaining(): number;
|
|
17
|
+
get(offset: number): number;
|
|
18
|
+
array(): Uint8Array | Uint16Array | Int32Array;
|
|
19
|
+
static builder(initialBufferSize: number): CodePointBuffer.Builder;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace CodePointBuffer {
|
|
22
|
+
class Builder {
|
|
23
|
+
private type;
|
|
24
|
+
private buffer;
|
|
25
|
+
private prevHighSurrogate;
|
|
26
|
+
private position;
|
|
27
|
+
constructor(initialBufferSize: number);
|
|
28
|
+
build(): CodePointBuffer;
|
|
29
|
+
private static roundUpToNextPowerOfTwo;
|
|
30
|
+
ensureRemaining(remainingNeeded: number): void;
|
|
31
|
+
append(utf16In: Uint16Array): void;
|
|
32
|
+
private appendArray;
|
|
33
|
+
private appendArrayByte;
|
|
34
|
+
private appendArrayChar;
|
|
35
|
+
private appendArrayInt;
|
|
36
|
+
private byteToCharBuffer;
|
|
37
|
+
private byteToIntBuffer;
|
|
38
|
+
private charToIntBuffer;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { CodePointBuffer } from "./CodePointBuffer";
|
|
7
|
+
import { Interval } from "./misc/Interval";
|
|
8
|
+
/**
|
|
9
|
+
* Alternative to {@link ANTLRInputStream} which treats the input
|
|
10
|
+
* as a series of Unicode code points, instead of a series of UTF-16
|
|
11
|
+
* code units.
|
|
12
|
+
*
|
|
13
|
+
* Use this if you need to parse input which potentially contains
|
|
14
|
+
* Unicode values > U+FFFF.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CodePointCharStream implements CharStream {
|
|
17
|
+
private readonly _array;
|
|
18
|
+
private readonly _size;
|
|
19
|
+
private readonly _name;
|
|
20
|
+
private _position;
|
|
21
|
+
protected constructor(array: Uint8Array | Uint16Array | Int32Array, position: number, remaining: number, name: string);
|
|
22
|
+
get internalStorage(): Uint8Array | Uint16Array | Int32Array;
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a {@link CodePointCharStream} which provides access
|
|
25
|
+
* to the Unicode code points stored in {@code codePointBuffer}.
|
|
26
|
+
*/
|
|
27
|
+
static fromBuffer(codePointBuffer: CodePointBuffer): CodePointCharStream;
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a named {@link CodePointCharStream} which provides access
|
|
30
|
+
* to the Unicode code points stored in {@code codePointBuffer}.
|
|
31
|
+
*/
|
|
32
|
+
static fromBuffer(codePointBuffer: CodePointBuffer, name: string): CodePointCharStream;
|
|
33
|
+
consume(): void;
|
|
34
|
+
get index(): number;
|
|
35
|
+
get size(): number;
|
|
36
|
+
/** mark/release do nothing; we have entire buffer */
|
|
37
|
+
mark(): number;
|
|
38
|
+
release(marker: number): void;
|
|
39
|
+
seek(index: number): void;
|
|
40
|
+
get sourceName(): string;
|
|
41
|
+
toString(): string;
|
|
42
|
+
LA(i: number): number;
|
|
43
|
+
/** Return the UTF-16 encoded string for the given interval */
|
|
44
|
+
getText(interval: Interval): string;
|
|
45
|
+
}
|