@cparra/apex-reflection 0.1.0-alpha.0 → 0.1.1-alpha.10
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/__tests__/end-to-end.test.ts +256 -0
- package/coverage/clover.xml +12857 -0
- package/coverage/coverage-final.json +3 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +126 -0
- package/coverage/lcov-report/index.js.html +104 -0
- package/coverage/lcov-report/out.js.html +41126 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov.info +24801 -0
- package/index.d.ts +118 -0
- package/index.js +8 -0
- package/index.ts +141 -0
- package/jest.config.js +11 -0
- package/out.js +13708 -0
- package/package.json +22 -17
- package/tsconfig.json +5 -3
- package/.idea/apexdocs-dart.iml +0 -18
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/libraries/Dart_Packages.xml +0 -556
- package/.idea/libraries/Dart_SDK.xml +0 -28
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/runConfigurations/_template__of_Dart_Test.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/CHANGELOG.md +0 -3
- package/README.md +0 -26
- package/TODO.md +0 -5
- package/analysis_options.yaml +0 -30
- package/antlr4-4.9.2/CHANGELOG.md +0 -4
- package/antlr4-4.9.2/LICENSE +0 -52
- package/antlr4-4.9.2/README.md +0 -11
- package/antlr4-4.9.2/analysis_options.yaml +0 -1
- package/antlr4-4.9.2/lib/antlr4.dart +0 -21
- package/antlr4-4.9.2/lib/src/atn/atn.dart +0 -18
- package/antlr4-4.9.2/lib/src/atn/src/atn.dart +0 -170
- package/antlr4-4.9.2/lib/src/atn/src/atn_config.dart +0 -242
- package/antlr4-4.9.2/lib/src/atn/src/atn_config_set.dart +0 -283
- package/antlr4-4.9.2/lib/src/atn/src/atn_deserializer.dart +0 -809
- package/antlr4-4.9.2/lib/src/atn/src/atn_simulator.dart +0 -95
- package/antlr4-4.9.2/lib/src/atn/src/atn_state.dart +0 -296
- package/antlr4-4.9.2/lib/src/atn/src/atn_type.dart +0 -14
- package/antlr4-4.9.2/lib/src/atn/src/info.dart +0 -553
- package/antlr4-4.9.2/lib/src/atn/src/lexer_action.dart +0 -601
- package/antlr4-4.9.2/lib/src/atn/src/lexer_action_executor.dart +0 -167
- package/antlr4-4.9.2/lib/src/atn/src/lexer_atn_simulator.dart +0 -731
- package/antlr4-4.9.2/lib/src/atn/src/parser_atn_simulator.dart +0 -2630
- package/antlr4-4.9.2/lib/src/atn/src/profiling_atn_simulator.dart +0 -229
- package/antlr4-4.9.2/lib/src/atn/src/semantic_context.dart +0 -404
- package/antlr4-4.9.2/lib/src/atn/src/transition.dart +0 -305
- package/antlr4-4.9.2/lib/src/dfa/dfa.dart +0 -8
- package/antlr4-4.9.2/lib/src/dfa/src/dfa.dart +0 -138
- package/antlr4-4.9.2/lib/src/dfa/src/dfa_serializer.dart +0 -76
- package/antlr4-4.9.2/lib/src/dfa/src/dfa_state.dart +0 -151
- package/antlr4-4.9.2/lib/src/error/error.dart +0 -10
- package/antlr4-4.9.2/lib/src/error/src/diagnostic_error_listener.dart +0 -116
- package/antlr4-4.9.2/lib/src/error/src/error_listener.dart +0 -241
- package/antlr4-4.9.2/lib/src/error/src/error_strategy.dart +0 -902
- package/antlr4-4.9.2/lib/src/error/src/errors.dart +0 -204
- package/antlr4-4.9.2/lib/src/input_stream.dart +0 -335
- package/antlr4-4.9.2/lib/src/interval_set.dart +0 -735
- package/antlr4-4.9.2/lib/src/lexer.dart +0 -343
- package/antlr4-4.9.2/lib/src/ll1_analyzer.dart +0 -204
- package/antlr4-4.9.2/lib/src/misc/multi_map.dart +0 -32
- package/antlr4-4.9.2/lib/src/misc/pair.dart +0 -34
- package/antlr4-4.9.2/lib/src/parser.dart +0 -777
- package/antlr4-4.9.2/lib/src/parser_interpreter.dart +0 -393
- package/antlr4-4.9.2/lib/src/parser_rule_context.dart +0 -275
- package/antlr4-4.9.2/lib/src/prediction_context.dart +0 -877
- package/antlr4-4.9.2/lib/src/recognizer.dart +0 -182
- package/antlr4-4.9.2/lib/src/rule_context.dart +0 -192
- package/antlr4-4.9.2/lib/src/runtime_meta_data.dart +0 -188
- package/antlr4-4.9.2/lib/src/token.dart +0 -431
- package/antlr4-4.9.2/lib/src/token_factory.dart +0 -88
- package/antlr4-4.9.2/lib/src/token_source.dart +0 -241
- package/antlr4-4.9.2/lib/src/token_stream.dart +0 -627
- package/antlr4-4.9.2/lib/src/tree/src/pattern/chunk.dart +0 -90
- package/antlr4-4.9.2/lib/src/tree/src/pattern/parse_tree_match.dart +0 -635
- package/antlr4-4.9.2/lib/src/tree/src/tree.dart +0 -370
- package/antlr4-4.9.2/lib/src/tree/src/trees.dart +0 -226
- package/antlr4-4.9.2/lib/src/tree/tree.dart +0 -10
- package/antlr4-4.9.2/lib/src/util/bit_set.dart +0 -308
- package/antlr4-4.9.2/lib/src/util/murmur_hash.dart +0 -77
- package/antlr4-4.9.2/lib/src/util/utils.dart +0 -31
- package/antlr4-4.9.2/lib/src/vocabulary.dart +0 -254
- package/antlr4-4.9.2/pubspec.yaml +0 -13
- package/example/node_example/index.js +0 -8
- package/example/node_example/package.json +0 -12
- package/example/node_example_ts/package-lock.json +0 -70
- package/example/node_example_ts/package.json +0 -19
- package/example/node_example_ts/src/index.js +0 -5
- package/example/node_example_ts/src/index.ts +0 -9
- package/example/node_example_ts/tsconfig.json +0 -79
- package/js/dart2jsout.js +0 -25898
- package/js/dart2jsout.js.map +0 -16
- package/js/index.d.ts +0 -1
- package/js/index.js +0 -4
- package/js/out.js +0 -26023
- package/js/out.js.map +0 -16
- package/js/package-lock.json +0 -57
- package/js/preamble.js +0 -125
- package/lib/apexdocs_dart.dart +0 -28
- package/lib/src/antlr/grammars/Apexdoc/ApexdocLexer.g4 +0 -120
- package/lib/src/antlr/grammars/Apexdoc/ApexdocParser.g4 +0 -158
- package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.interp +0 -95
- package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.java +0 -238
- package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.tokens +0 -23
- package/lib/src/antlr/grammars/apex/ApexLexer.g4 +0 -255
- package/lib/src/antlr/grammars/apex/ApexParser.g4 +0 -567
- package/lib/src/antlr/grammars/apex/examples/ApexClass.cls +0 -6
- package/lib/src/antlr/lib/apex/ApexLexer.dart +0 -1223
- package/lib/src/antlr/lib/apex/ApexLexer.interp +0 -393
- package/lib/src/antlr/lib/apex/ApexLexer.tokens +0 -212
- package/lib/src/antlr/lib/apex/ApexParser.dart +0 -9349
- package/lib/src/antlr/lib/apex/ApexParser.interp +0 -326
- package/lib/src/antlr/lib/apex/ApexParser.tokens +0 -212
- package/lib/src/antlr/lib/apex/ApexParserBaseListener.dart +0 -1036
- package/lib/src/antlr/lib/apex/ApexParserListener.dart +0 -975
- package/lib/src/antlr/lib/apexdoc/ApexdocLexer.dart +0 -373
- package/lib/src/antlr/lib/apexdoc/ApexdocLexer.interp +0 -95
- package/lib/src/antlr/lib/apexdoc/ApexdocLexer.tokens +0 -23
- package/lib/src/antlr/lib/apexdoc/ApexdocParser.dart +0 -2471
- package/lib/src/antlr/lib/apexdoc/ApexdocParser.interp +0 -69
- package/lib/src/antlr/lib/apexdoc/ApexdocParser.tokens +0 -23
- package/lib/src/antlr/lib/apexdoc/ApexdocParserBaseListener.dart +0 -252
- package/lib/src/antlr/lib/apexdoc/ApexdocParserListener.dart +0 -215
- package/lib/src/builders/builders.dart +0 -32
- package/lib/src/model/apex_file_manifest.dart +0 -37
- package/lib/src/model/apex_file_manifest.g.dart +0 -18
- package/lib/src/model/declaration.dart +0 -50
- package/lib/src/model/doc_comment.dart +0 -117
- package/lib/src/model/doc_comment.g.dart +0 -118
- package/lib/src/model/members.dart +0 -143
- package/lib/src/model/members.g.dart +0 -105
- package/lib/src/model/types.dart +0 -159
- package/lib/src/model/types.g.dart +0 -111
- package/lib/src/service/apex_listener.dart +0 -226
- package/lib/src/service/apexdoc_listener.dart +0 -82
- package/lib/src/service/parsers.dart +0 -33
- package/lib/src/service/utils/parsing/access_modifiers_parser.dart +0 -33
- package/lib/src/service/utils/parsing/parameters_parser.dart +0 -18
- package/lib/src/service/utils/parsing/parsing_utils.dart +0 -2
- package/lib/src/service/walker.dart +0 -82
- package/pubspec.yaml +0 -19
- package/test/apex_file_manifest_test.dart +0 -16
- package/test/apex_listener_test.dart +0 -703
- package/test/apexdoc_parser_test.dart +0 -179
- package/test/doc_comment_test.dart +0 -89
- package/test/members_serialization_test.dart +0 -158
- package/test/members_test.dart +0 -178
- package/test/types_serialization_test.dart +0 -191
- package/test/types_test.dart +0 -311
- package/test/walker_test.dart +0 -58
- package/tool/grind.dart +0 -20
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
3
|
-
* Use of this file is governed by the BSD 3-clause license that
|
|
4
|
-
* can be found in the LICENSE.txt file in the project root.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import '../../atn/atn.dart';
|
|
8
|
-
import '../../input_stream.dart';
|
|
9
|
-
import '../../interval_set.dart';
|
|
10
|
-
import '../../lexer.dart';
|
|
11
|
-
import '../../parser.dart';
|
|
12
|
-
import '../../parser_rule_context.dart';
|
|
13
|
-
import '../../recognizer.dart';
|
|
14
|
-
import '../../rule_context.dart';
|
|
15
|
-
import '../../token.dart';
|
|
16
|
-
import '../../token_stream.dart';
|
|
17
|
-
import '../../util/utils.dart';
|
|
18
|
-
|
|
19
|
-
/// The root of the ANTLR exception hierarchy. In general, ANTLR tracks just
|
|
20
|
-
/// 3 kinds of errors: prediction errors, failed predicate errors, and
|
|
21
|
-
/// mismatched input errors. In each case, the parser knows where it is
|
|
22
|
-
/// in the input, where it is in the ATN, the rule invocation stack,
|
|
23
|
-
/// and what kind of problem occurred.
|
|
24
|
-
class RecognitionException extends StateError {
|
|
25
|
-
/// Gets the [Recognizer] where this exception occurred.
|
|
26
|
-
///
|
|
27
|
-
/// <p>If the recognizer is not available, this method returns null.</p>
|
|
28
|
-
///
|
|
29
|
-
/// @return The recognizer where this exception occurred, or null if
|
|
30
|
-
/// the recognizer is not available.
|
|
31
|
-
final Recognizer recognizer;
|
|
32
|
-
|
|
33
|
-
/// Gets the [RuleContext] at the time this exception was thrown.
|
|
34
|
-
///
|
|
35
|
-
/// <p>If the context is not available, this method returns null.</p>
|
|
36
|
-
///
|
|
37
|
-
/// @return The [RuleContext] at the time this exception was thrown.
|
|
38
|
-
/// If the context is not available, this method returns null.
|
|
39
|
-
final RuleContext ctx;
|
|
40
|
-
|
|
41
|
-
/// Gets the input stream which is the symbol source for the recognizer where
|
|
42
|
-
/// this exception was thrown.
|
|
43
|
-
///
|
|
44
|
-
/// <p>If the input stream is not available, this method returns null.</p>
|
|
45
|
-
///
|
|
46
|
-
/// @return The input stream which is the symbol source for the recognizer
|
|
47
|
-
/// where this exception was thrown, or null if the stream is not
|
|
48
|
-
/// available.
|
|
49
|
-
final IntStream inputStream;
|
|
50
|
-
|
|
51
|
-
/// The current [Token] when an error occurred. Since not all streams
|
|
52
|
-
/// support accessing symbols by index, we have to track the [Token]
|
|
53
|
-
/// instance itself.
|
|
54
|
-
Token offendingToken;
|
|
55
|
-
|
|
56
|
-
/// Get the ATN state number the parser was in at the time the error
|
|
57
|
-
/// occurred. For [NoViableAltException] and
|
|
58
|
-
/// [LexerNoViableAltException] exceptions, this is the
|
|
59
|
-
/// [DecisionState] number. For others, it is the state whose outgoing
|
|
60
|
-
/// edge we couldn't match.
|
|
61
|
-
///
|
|
62
|
-
/// <p>If the state number is not known, this method returns -1.</p>
|
|
63
|
-
int offendingState = -1;
|
|
64
|
-
|
|
65
|
-
RecognitionException(this.recognizer, this.inputStream, this.ctx,
|
|
66
|
-
[String message = ''])
|
|
67
|
-
: super(message) {
|
|
68
|
-
if (recognizer != null) offendingState = recognizer.state;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/// Gets the set of input symbols which could potentially follow the
|
|
72
|
-
/// previously matched symbol at the time this exception was thrown.
|
|
73
|
-
///
|
|
74
|
-
/// <p>If the set of expected tokens is not known and could not be computed,
|
|
75
|
-
/// this method returns null.</p>
|
|
76
|
-
///
|
|
77
|
-
/// @return The set of token types that could potentially follow the current
|
|
78
|
-
/// state in the ATN, or null if the information is not available.
|
|
79
|
-
IntervalSet get expectedTokens {
|
|
80
|
-
if (recognizer != null) {
|
|
81
|
-
return recognizer.getATN().getExpectedTokens(offendingState, ctx);
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
class LexerNoViableAltException extends RecognitionException {
|
|
88
|
-
/// Matching attempted at what input index? */
|
|
89
|
-
final int startIndex;
|
|
90
|
-
|
|
91
|
-
/// Which configurations did we try at input.index() that couldn't match input.LA(1)? */
|
|
92
|
-
final ATNConfigSet deadEndConfigs;
|
|
93
|
-
|
|
94
|
-
LexerNoViableAltException(
|
|
95
|
-
Lexer lexer, CharStream input, this.startIndex, this.deadEndConfigs)
|
|
96
|
-
: super(lexer, input, null);
|
|
97
|
-
|
|
98
|
-
@override
|
|
99
|
-
CharStream get inputStream {
|
|
100
|
-
return super.inputStream;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@override
|
|
104
|
-
String toString() {
|
|
105
|
-
var symbol = '';
|
|
106
|
-
if (startIndex >= 0 && startIndex < inputStream.size) {
|
|
107
|
-
symbol = inputStream.getText(Interval.of(startIndex, startIndex));
|
|
108
|
-
symbol = escapeWhitespace(symbol);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return "${LexerNoViableAltException}('${symbol}')";
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/// Indicates that the parser could not decide which of two or more paths
|
|
116
|
-
/// to take based upon the remaining input. It tracks the starting token
|
|
117
|
-
/// of the offending input and also knows where the parser was
|
|
118
|
-
/// in the various paths when the error. Reported by reportNoViableAlternative()
|
|
119
|
-
class NoViableAltException extends RecognitionException {
|
|
120
|
-
/// Which configurations did we try at input.index() that couldn't match input.LT(1)? */
|
|
121
|
-
|
|
122
|
-
final ATNConfigSet deadEndConfigs;
|
|
123
|
-
|
|
124
|
-
/// The token object at the start index; the input stream might
|
|
125
|
-
/// not be buffering tokens so get a reference to it. (At the
|
|
126
|
-
/// time the error occurred, of course the stream needs to keep a
|
|
127
|
-
/// buffer all of the tokens but later we might not have access to those.)
|
|
128
|
-
|
|
129
|
-
final Token startToken;
|
|
130
|
-
|
|
131
|
-
// NoViableAltException(Parser recognizer) { // LL(1) error
|
|
132
|
-
// this(recognizer,
|
|
133
|
-
// recognizer.inputStream,
|
|
134
|
-
// recognizer.getCurrentToken(),
|
|
135
|
-
// recognizer.getCurrentToken(),
|
|
136
|
-
// null,
|
|
137
|
-
// recognizer._ctx);
|
|
138
|
-
// }
|
|
139
|
-
|
|
140
|
-
NoViableAltException._(Parser recognizer, TokenStream input, this.startToken,
|
|
141
|
-
Token offendingToken, this.deadEndConfigs, ParserRuleContext ctx)
|
|
142
|
-
: super(recognizer, input, ctx) {
|
|
143
|
-
this.offendingToken = offendingToken;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
NoViableAltException(Parser recognizer,
|
|
147
|
-
[TokenStream input,
|
|
148
|
-
Token startToken,
|
|
149
|
-
Token offendingToken,
|
|
150
|
-
ATNConfigSet deadEndConfigs,
|
|
151
|
-
ParserRuleContext ctx])
|
|
152
|
-
: this._(
|
|
153
|
-
recognizer,
|
|
154
|
-
input ?? recognizer.inputStream,
|
|
155
|
-
startToken ?? recognizer.currentToken,
|
|
156
|
-
offendingToken ?? recognizer.currentToken,
|
|
157
|
-
deadEndConfigs,
|
|
158
|
-
ctx ?? recognizer.context);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/// This signifies any kind of mismatched input exceptions such as
|
|
162
|
-
/// when the current input does not match the expected token.
|
|
163
|
-
class InputMismatchException extends RecognitionException {
|
|
164
|
-
InputMismatchException(Parser recognizer,
|
|
165
|
-
[int state = -1, ParserRuleContext ctx])
|
|
166
|
-
: super(recognizer, recognizer.inputStream, ctx ?? recognizer.context) {
|
|
167
|
-
if (state != -1 && ctx != null) {
|
|
168
|
-
offendingState = state;
|
|
169
|
-
}
|
|
170
|
-
offendingToken = recognizer.currentToken;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/// A semantic predicate failed during validation. Validation of predicates
|
|
175
|
-
/// occurs when normally parsing the alternative just like matching a token.
|
|
176
|
-
/// Disambiguating predicate evaluation occurs when we test a predicate during
|
|
177
|
-
/// prediction.
|
|
178
|
-
class FailedPredicateException extends RecognitionException {
|
|
179
|
-
int ruleIndex;
|
|
180
|
-
int predIndex;
|
|
181
|
-
final String predicate;
|
|
182
|
-
|
|
183
|
-
FailedPredicateException(Parser recognizer,
|
|
184
|
-
[this.predicate, String message])
|
|
185
|
-
: super(recognizer, recognizer.inputStream, recognizer.context,
|
|
186
|
-
formatMessage(predicate, message)) {
|
|
187
|
-
final s = recognizer.interpreter.atn.states[recognizer.state];
|
|
188
|
-
|
|
189
|
-
AbstractPredicateTransition trans = s.transition(0);
|
|
190
|
-
if (trans is PredicateTransition) {
|
|
191
|
-
ruleIndex = trans.ruleIndex;
|
|
192
|
-
predIndex = trans.predIndex;
|
|
193
|
-
}
|
|
194
|
-
offendingToken = recognizer.currentToken;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
static String formatMessage(String predicate, String message) {
|
|
198
|
-
if (message != null) {
|
|
199
|
-
return message;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return 'failed predicate: {$predicate}?';
|
|
203
|
-
}
|
|
204
|
-
}
|
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
3
|
-
* Use of this file is governed by the BSD 3-clause license that
|
|
4
|
-
* can be found in the LICENSE.txt file in the project root.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import 'dart:async';
|
|
8
|
-
import 'dart:convert';
|
|
9
|
-
import 'dart:io';
|
|
10
|
-
import 'dart:math';
|
|
11
|
-
|
|
12
|
-
import 'interval_set.dart';
|
|
13
|
-
import 'token.dart';
|
|
14
|
-
|
|
15
|
-
/// A simple stream of symbols whose values are represented as integers. This
|
|
16
|
-
/// interface provides <em>marked ranges</em> with support for a minimum level
|
|
17
|
-
/// of buffering necessary to implement arbitrary lookahead during prediction.
|
|
18
|
-
/// For more information on marked ranges, see {@link #mark}.
|
|
19
|
-
///
|
|
20
|
-
/// <p><strong>Initializing Methods:</strong> Some methods in this interface have
|
|
21
|
-
/// unspecified behavior if no call to an initializing method has occurred after
|
|
22
|
-
/// the stream was constructed. The following is a list of initializing methods:</p>
|
|
23
|
-
///
|
|
24
|
-
/// <ul>
|
|
25
|
-
/// <li>{@link #LA}</li>
|
|
26
|
-
/// <li>{@link #consume}</li>
|
|
27
|
-
/// <li>{@link #size}</li>
|
|
28
|
-
/// </ul>
|
|
29
|
-
abstract class IntStream {
|
|
30
|
-
/// The value returned by {@link #LA LA()} when the end of the stream is
|
|
31
|
-
/// reached.
|
|
32
|
-
static const int EOF = -1;
|
|
33
|
-
|
|
34
|
-
/// The value returned by {@link #getSourceName} when the actual name of the
|
|
35
|
-
/// underlying source is not known.
|
|
36
|
-
static const UNKNOWN_SOURCE_NAME = '<unknown>';
|
|
37
|
-
|
|
38
|
-
/// Consumes the current symbol in the stream. This method has the following
|
|
39
|
-
/// effects:
|
|
40
|
-
///
|
|
41
|
-
/// <ul>
|
|
42
|
-
/// <li><strong>Forward movement:</strong> The value of {@link #index index()}
|
|
43
|
-
/// before calling this method is less than the value of {@code index()}
|
|
44
|
-
/// after calling this method.</li>
|
|
45
|
-
/// <li><strong>Ordered lookahead:</strong> The value of {@code LA(1)} before
|
|
46
|
-
/// calling this method becomes the value of {@code LA(-1)} after calling
|
|
47
|
-
/// this method.</li>
|
|
48
|
-
/// </ul>
|
|
49
|
-
///
|
|
50
|
-
/// Note that calling this method does not guarantee that {@code index()} is
|
|
51
|
-
/// incremented by exactly 1, as that would preclude the ability to implement
|
|
52
|
-
/// filtering streams (e.g. [CommonTokenStream] which distinguishes
|
|
53
|
-
/// between "on-channel" and "off-channel" tokens).
|
|
54
|
-
///
|
|
55
|
-
/// @throws IllegalStateException if an attempt is made to consume the
|
|
56
|
-
/// end of the stream (i.e. if {@code LA(1)==}{@link #EOF EOF} before calling
|
|
57
|
-
/// [consume]).
|
|
58
|
-
void consume();
|
|
59
|
-
|
|
60
|
-
/// Gets the value of the symbol at offset [i] from the current
|
|
61
|
-
/// position. When {@code i==1}, this method returns the value of the current
|
|
62
|
-
/// symbol in the stream (which is the next symbol to be consumed). When
|
|
63
|
-
/// {@code i==-1}, this method returns the value of the previously read
|
|
64
|
-
/// symbol in the stream. It is not valid to call this method with
|
|
65
|
-
/// {@code i==0}, but the specific behavior is unspecified because this
|
|
66
|
-
/// method is frequently called from performance-critical code.
|
|
67
|
-
///
|
|
68
|
-
/// <p>This method is guaranteed to succeed if any of the following are true:</p>
|
|
69
|
-
///
|
|
70
|
-
/// <ul>
|
|
71
|
-
/// <li>{@code i>0}</li>
|
|
72
|
-
/// <li>{@code i==-1} and {@link #index index()} returns a value greater
|
|
73
|
-
/// than the value of {@code index()} after the stream was constructed
|
|
74
|
-
/// and {@code LA(1)} was called in that order. Specifying the current
|
|
75
|
-
/// {@code index()} relative to the index after the stream was created
|
|
76
|
-
/// allows for filtering implementations that do not return every symbol
|
|
77
|
-
/// from the underlying source. Specifying the call to {@code LA(1)}
|
|
78
|
-
/// allows for lazily initialized streams.</li>
|
|
79
|
-
/// <li>{@code LA(i)} refers to a symbol consumed within a marked region
|
|
80
|
-
/// that has not yet been released.</li>
|
|
81
|
-
/// </ul>
|
|
82
|
-
///
|
|
83
|
-
/// <p>If [i] represents a position at or beyond the end of the stream,
|
|
84
|
-
/// this method returns {@link #EOF}.</p>
|
|
85
|
-
///
|
|
86
|
-
/// <p>The return value is unspecified if {@code i<0} and fewer than {@code -i}
|
|
87
|
-
/// calls to {@link #consume consume()} have occurred from the beginning of
|
|
88
|
-
/// the stream before calling this method.</p>
|
|
89
|
-
///
|
|
90
|
-
/// @throws UnsupportedOperationException if the stream does not support
|
|
91
|
-
/// retrieving the value of the specified symbol
|
|
92
|
-
int LA(int i);
|
|
93
|
-
|
|
94
|
-
/// A mark provides a guarantee that {@link #seek seek()} operations will be
|
|
95
|
-
/// valid over a "marked range" extending from the index where {@code mark()}
|
|
96
|
-
/// was called to the current {@link #index index()}. This allows the use of
|
|
97
|
-
/// streaming input sources by specifying the minimum buffering requirements
|
|
98
|
-
/// to support arbitrary lookahead during prediction.
|
|
99
|
-
///
|
|
100
|
-
/// <p>The returned mark is an opaque handle (type [int]) which is passed
|
|
101
|
-
/// to {@link #release release()} when the guarantees provided by the marked
|
|
102
|
-
/// range are no longer necessary. When calls to
|
|
103
|
-
/// {@code mark()}/{@code release()} are nested, the marks must be released
|
|
104
|
-
/// in reverse order of which they were obtained. Since marked regions are
|
|
105
|
-
/// used during performance-critical sections of prediction, the specific
|
|
106
|
-
/// behavior of invalid usage is unspecified (i.e. a mark is not released, or
|
|
107
|
-
/// a mark is released twice, or marks are not released in reverse order from
|
|
108
|
-
/// which they were created).</p>
|
|
109
|
-
///
|
|
110
|
-
/// <p>The behavior of this method is unspecified if no call to an
|
|
111
|
-
/// {@link IntStream initializing method} has occurred after this stream was
|
|
112
|
-
/// constructed.</p>
|
|
113
|
-
///
|
|
114
|
-
/// <p>This method does not change the current position in the input stream.</p>
|
|
115
|
-
///
|
|
116
|
-
/// <p>The following example shows the use of {@link #mark mark()},
|
|
117
|
-
/// {@link #release release(mark)}, {@link #index index()}, and
|
|
118
|
-
/// {@link #seek seek(index)} as part of an operation to safely work within a
|
|
119
|
-
/// marked region, then restore the stream position to its original value and
|
|
120
|
-
/// release the mark.</p>
|
|
121
|
-
/// <pre>
|
|
122
|
-
/// IntStream stream = ...;
|
|
123
|
-
/// int index = -1;
|
|
124
|
-
/// int mark = stream.mark();
|
|
125
|
-
/// try {
|
|
126
|
-
/// index = stream.index();
|
|
127
|
-
/// // perform work here...
|
|
128
|
-
/// } finally {
|
|
129
|
-
/// if (index != -1) {
|
|
130
|
-
/// stream.seek(index);
|
|
131
|
-
/// }
|
|
132
|
-
/// stream.release(mark);
|
|
133
|
-
/// }
|
|
134
|
-
/// </pre>
|
|
135
|
-
///
|
|
136
|
-
/// @return An opaque marker which should be passed to
|
|
137
|
-
/// {@link #release release()} when the marked range is no longer required.
|
|
138
|
-
int mark();
|
|
139
|
-
|
|
140
|
-
/// This method releases a marked range created by a call to
|
|
141
|
-
/// {@link #mark mark()}. Calls to {@code release()} must appear in the
|
|
142
|
-
/// reverse order of the corresponding calls to {@code mark()}. If a mark is
|
|
143
|
-
/// released twice, or if marks are not released in reverse order of the
|
|
144
|
-
/// corresponding calls to {@code mark()}, the behavior is unspecified.
|
|
145
|
-
///
|
|
146
|
-
/// <p>For more information and an example, see {@link #mark}.</p>
|
|
147
|
-
///
|
|
148
|
-
/// @param marker A marker returned by a call to {@code mark()}.
|
|
149
|
-
/// @see #mark
|
|
150
|
-
void release(int marker);
|
|
151
|
-
|
|
152
|
-
/// Return the index into the stream of the input symbol referred to by
|
|
153
|
-
/// {@code LA(1)}.
|
|
154
|
-
///
|
|
155
|
-
/// <p>The behavior of this method is unspecified if no call to an
|
|
156
|
-
/// {@link IntStream initializing method} has occurred after this stream was
|
|
157
|
-
/// constructed.</p>
|
|
158
|
-
int get index;
|
|
159
|
-
|
|
160
|
-
/// Set the input cursor to the position indicated by [index]. If the
|
|
161
|
-
/// specified index lies past the end of the stream, the operation behaves as
|
|
162
|
-
/// though [index] was the index of the EOF symbol. After this method
|
|
163
|
-
/// returns without throwing an exception, then at least one of the following
|
|
164
|
-
/// will be true.
|
|
165
|
-
///
|
|
166
|
-
/// <ul>
|
|
167
|
-
/// <li>{@link #index index()} will return the index of the first symbol
|
|
168
|
-
/// appearing at or after the specified [index]. Specifically,
|
|
169
|
-
/// implementations which filter their sources should automatically
|
|
170
|
-
/// adjust [index] forward the minimum amount required for the
|
|
171
|
-
/// operation to target a non-ignored symbol.</li>
|
|
172
|
-
/// <li>{@code LA(1)} returns {@link #EOF}</li>
|
|
173
|
-
/// </ul>
|
|
174
|
-
///
|
|
175
|
-
/// This operation is guaranteed to not throw an exception if [index]
|
|
176
|
-
/// lies within a marked region. For more information on marked regions, see
|
|
177
|
-
/// {@link #mark}. The behavior of this method is unspecified if no call to
|
|
178
|
-
/// an {@link IntStream initializing method} has occurred after this stream
|
|
179
|
-
/// was constructed.
|
|
180
|
-
///
|
|
181
|
-
/// @param index The absolute index to seek to.
|
|
182
|
-
///
|
|
183
|
-
/// @throws IllegalArgumentException if [index] is less than 0
|
|
184
|
-
/// @throws UnsupportedOperationException if the stream does not support
|
|
185
|
-
/// seeking to the specified index
|
|
186
|
-
void seek(int index);
|
|
187
|
-
|
|
188
|
-
/// Returns the total number of symbols in the stream, including a single EOF
|
|
189
|
-
/// symbol.
|
|
190
|
-
///
|
|
191
|
-
/// @throws UnsupportedOperationException if the size of the stream is
|
|
192
|
-
/// unknown.
|
|
193
|
-
int get size;
|
|
194
|
-
|
|
195
|
-
/// Gets the name of the underlying symbol source. This method returns a
|
|
196
|
-
/// non-null, non-empty string. If such a name is not known, this method
|
|
197
|
-
/// returns {@link #UNKNOWN_SOURCE_NAME}.
|
|
198
|
-
|
|
199
|
-
String get sourceName;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/// A source of characters for an ANTLR lexer. */
|
|
203
|
-
abstract class CharStream extends IntStream {
|
|
204
|
-
/// This method returns the text for a range of characters within this input
|
|
205
|
-
/// stream. This method is guaranteed to not throw an exception if the
|
|
206
|
-
/// specified [interval] lies entirely within a marked range. For more
|
|
207
|
-
/// information about marked ranges, see {@link IntStream#mark}.
|
|
208
|
-
///
|
|
209
|
-
/// @param interval an interval within the stream
|
|
210
|
-
/// @return the text of the specified interval
|
|
211
|
-
///
|
|
212
|
-
/// @throws NullPointerException if [interval] is null
|
|
213
|
-
/// @throws IllegalArgumentException if {@code interval.a < 0}, or if
|
|
214
|
-
/// {@code interval.b < interval.a - 1}, or if {@code interval.b} lies at or
|
|
215
|
-
/// past the end of the stream
|
|
216
|
-
/// @throws UnsupportedOperationException if the stream does not support
|
|
217
|
-
/// getting the text of the specified interval
|
|
218
|
-
String getText(Interval interval);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Vacuum all input from a string and then treat it like a buffer.
|
|
222
|
-
class InputStream extends CharStream {
|
|
223
|
-
final name = '<empty>';
|
|
224
|
-
List<int> data;
|
|
225
|
-
int _index = 0;
|
|
226
|
-
bool decodeToUnicodeCodePoints = false;
|
|
227
|
-
|
|
228
|
-
InputStream(List<int> data) {
|
|
229
|
-
this.data = data;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
InputStream.fromString(String data) {
|
|
233
|
-
this.data = data.runes.toList(growable: false);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
static Future<InputStream> fromStringStream(Stream<String> stream) async {
|
|
237
|
-
final data = StringBuffer();
|
|
238
|
-
await stream.listen((buf) {
|
|
239
|
-
data.write(buf);
|
|
240
|
-
}).asFuture();
|
|
241
|
-
return InputStream.fromString(data.toString());
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
static Future<InputStream> fromStream(Stream<List<int>> stream,
|
|
245
|
-
{Encoding encoding = utf8}) {
|
|
246
|
-
final data = stream.transform(encoding.decoder);
|
|
247
|
-
return fromStringStream(data);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
static Future<InputStream> fromPath(String path, {Encoding encoding = utf8}) {
|
|
251
|
-
return fromStream(File(path).openRead());
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
@override
|
|
255
|
-
int get index {
|
|
256
|
-
return _index;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@override
|
|
260
|
-
int get size {
|
|
261
|
-
return data.length;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/// Reset the stream so that it's in the same state it was
|
|
265
|
-
/// when the object was created *except* the data array is not
|
|
266
|
-
/// touched.
|
|
267
|
-
void reset() {
|
|
268
|
-
_index = 0;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
@override
|
|
272
|
-
void consume() {
|
|
273
|
-
if (_index >= size) {
|
|
274
|
-
// assert this.LA(1) == Token.EOF
|
|
275
|
-
throw ('cannot consume EOF');
|
|
276
|
-
}
|
|
277
|
-
_index += 1;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
@override
|
|
281
|
-
int LA(int offset) {
|
|
282
|
-
if (offset == 0) {
|
|
283
|
-
return 0; // undefined
|
|
284
|
-
}
|
|
285
|
-
if (offset < 0) {
|
|
286
|
-
offset += 1; // e.g., translate LA(-1) to use offset=0
|
|
287
|
-
}
|
|
288
|
-
final pos = _index + offset - 1;
|
|
289
|
-
if (pos < 0 || pos >= size) {
|
|
290
|
-
// invalid
|
|
291
|
-
return Token.EOF;
|
|
292
|
-
}
|
|
293
|
-
return data[pos];
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/// mark/release do nothing; we have entire buffer
|
|
297
|
-
@override
|
|
298
|
-
int mark() {
|
|
299
|
-
return -1;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
@override
|
|
303
|
-
void release(int marker) {}
|
|
304
|
-
|
|
305
|
-
/// consume() ahead until p==_index; can't just set p=_index as we must
|
|
306
|
-
/// update line and column. If we seek backwards, just set p
|
|
307
|
-
@override
|
|
308
|
-
void seek(int _index) {
|
|
309
|
-
if (_index <= this._index) {
|
|
310
|
-
this._index = _index; // just jump; don't update stream state (line,
|
|
311
|
-
// ...)
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
// seek forward
|
|
315
|
-
this._index = min(_index, size);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
@override
|
|
319
|
-
String getText(Interval interval) {
|
|
320
|
-
final startIdx = min(interval.a, size);
|
|
321
|
-
final len = min(interval.b - interval.a + 1, size - startIdx);
|
|
322
|
-
return String.fromCharCodes(data, startIdx, startIdx + len);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
@override
|
|
326
|
-
String toString() {
|
|
327
|
-
return String.fromCharCodes(data);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
@override
|
|
331
|
-
String get sourceName {
|
|
332
|
-
// TODO: implement getSourceName
|
|
333
|
-
return IntStream.UNKNOWN_SOURCE_NAME;
|
|
334
|
-
}
|
|
335
|
-
}
|