@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,305 +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 '../../interval_set.dart';
|
|
8
|
-
import '../../token.dart';
|
|
9
|
-
import 'atn_state.dart';
|
|
10
|
-
import 'semantic_context.dart';
|
|
11
|
-
|
|
12
|
-
enum TransitionType {
|
|
13
|
-
INVALID, // 0 is not used
|
|
14
|
-
EPSILON,
|
|
15
|
-
RANGE,
|
|
16
|
-
RULE,
|
|
17
|
-
PREDICATE, // e.g., {isType(input.LT(1))}?
|
|
18
|
-
ATOM,
|
|
19
|
-
ACTION,
|
|
20
|
-
SET, // ~(A|B) or ~atom, wildcard, which convert to next 2
|
|
21
|
-
NOT_SET,
|
|
22
|
-
WILDCARD,
|
|
23
|
-
PRECEDENCE,
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/// An ATN transition between any two ATN states. Subclasses define
|
|
27
|
-
/// atom, set, epsilon, action, predicate, rule transitions.
|
|
28
|
-
///
|
|
29
|
-
/// <p>This is a one way link. It emanates from a state (usually via a list of
|
|
30
|
-
/// transitions) and has a target state.</p>
|
|
31
|
-
///
|
|
32
|
-
/// <p>Since we never have to change the ATN transitions once we construct it,
|
|
33
|
-
/// we can fix these transitions as specific classes. The DFA transitions
|
|
34
|
-
/// on the other hand need to update the labels as it adds transitions to
|
|
35
|
-
/// the states. We'll use the term Edge for the DFA to distinguish them from
|
|
36
|
-
/// ATN transitions.</p>
|
|
37
|
-
abstract class Transition {
|
|
38
|
-
/// The target of this transition. */
|
|
39
|
-
ATNState target;
|
|
40
|
-
|
|
41
|
-
Transition(this.target) {
|
|
42
|
-
if (target == null) {
|
|
43
|
-
throw ArgumentError.notNull('target cannot be null.');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
TransitionType get type;
|
|
48
|
-
|
|
49
|
-
/// Determines if the transition is an "epsilon" transition.
|
|
50
|
-
///
|
|
51
|
-
/// <p>The default implementation returns [false].</p>
|
|
52
|
-
///
|
|
53
|
-
/// @return [true] if traversing this transition in the ATN does not
|
|
54
|
-
/// consume an input symbol; otherwise, [false] if traversing this
|
|
55
|
-
/// transition consumes (matches) an input symbol.
|
|
56
|
-
bool get isEpsilon => false;
|
|
57
|
-
|
|
58
|
-
IntervalSet get label => null;
|
|
59
|
-
|
|
60
|
-
bool matches(int symbol, int minVocabSymbol, int maxVocabSymbol);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
class EpsilonTransition extends Transition {
|
|
64
|
-
/// @return the rule index of a precedence rule for which this transition is
|
|
65
|
-
/// returning from, where the precedence value is 0; otherwise, -1.
|
|
66
|
-
///
|
|
67
|
-
/// @see ATNConfig#isPrecedenceFilterSuppressed()
|
|
68
|
-
/// @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet)
|
|
69
|
-
/// @since 4.4.1
|
|
70
|
-
final int outermostPrecedenceReturn;
|
|
71
|
-
|
|
72
|
-
EpsilonTransition(ATNState target, [this.outermostPrecedenceReturn = -1])
|
|
73
|
-
: super(target);
|
|
74
|
-
|
|
75
|
-
@override
|
|
76
|
-
bool get isEpsilon => true;
|
|
77
|
-
|
|
78
|
-
@override
|
|
79
|
-
bool matches(int symbol, int minVocabSymbol, int maxVocabSymbol) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@override
|
|
84
|
-
String toString() {
|
|
85
|
-
return 'epsilon';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@override
|
|
89
|
-
TransitionType get type => TransitionType.EPSILON;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
class RangeTransition extends Transition {
|
|
93
|
-
final int from;
|
|
94
|
-
final int to;
|
|
95
|
-
|
|
96
|
-
RangeTransition(ATNState target, this.from, this.to) : super(target);
|
|
97
|
-
|
|
98
|
-
@override
|
|
99
|
-
IntervalSet get label {
|
|
100
|
-
return IntervalSet.ofRange(from, to);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@override
|
|
104
|
-
bool matches(int symbol, int minVocabSymbol, int maxVocabSymbol) {
|
|
105
|
-
return symbol >= from && symbol <= to;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@override
|
|
109
|
-
String toString() {
|
|
110
|
-
return "'$from..$to'";
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
@override
|
|
114
|
-
TransitionType get type => TransitionType.RANGE;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class RuleTransition extends Transition {
|
|
118
|
-
/// Ptr to the rule definition object for this rule ref */
|
|
119
|
-
final int ruleIndex; // no Rule object at runtime
|
|
120
|
-
|
|
121
|
-
final int precedence;
|
|
122
|
-
|
|
123
|
-
/// What node to begin computations following ref to rule */
|
|
124
|
-
ATNState followState;
|
|
125
|
-
|
|
126
|
-
RuleTransition(RuleStartState ruleStart, this.ruleIndex, this.precedence,
|
|
127
|
-
this.followState)
|
|
128
|
-
: super(ruleStart);
|
|
129
|
-
|
|
130
|
-
@override
|
|
131
|
-
bool get isEpsilon => true;
|
|
132
|
-
|
|
133
|
-
@override
|
|
134
|
-
bool matches(int symbol, int minVocabSymbol, int maxVocabSymbol) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@override
|
|
139
|
-
TransitionType get type => TransitionType.RULE;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
abstract class AbstractPredicateTransition extends Transition {
|
|
143
|
-
AbstractPredicateTransition(ATNState target) : super(target);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
class PredicateTransition extends AbstractPredicateTransition {
|
|
147
|
-
final int ruleIndex;
|
|
148
|
-
final int predIndex;
|
|
149
|
-
final bool isCtxDependent; // e.g., $i ref in pred
|
|
150
|
-
|
|
151
|
-
PredicateTransition(
|
|
152
|
-
target, this.ruleIndex, this.predIndex, this.isCtxDependent)
|
|
153
|
-
: super(target);
|
|
154
|
-
|
|
155
|
-
@override
|
|
156
|
-
bool get isEpsilon => true;
|
|
157
|
-
|
|
158
|
-
@override
|
|
159
|
-
bool matches(symbol, minVocabSymbol, maxVocabSymbol) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
Predicate get predicate => Predicate(ruleIndex, predIndex, isCtxDependent);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
@override
|
|
167
|
-
String toString() {
|
|
168
|
-
return 'pred_$ruleIndex:$predIndex';
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@override
|
|
172
|
-
TransitionType get type => TransitionType.PREDICATE;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/// TODO: make all transitions sets? no, should remove set edges */
|
|
176
|
-
class AtomTransition extends Transition {
|
|
177
|
-
/// The token type or character value; or, signifies special label. */
|
|
178
|
-
final int atomLabel;
|
|
179
|
-
|
|
180
|
-
AtomTransition(ATNState target, this.atomLabel) : super(target);
|
|
181
|
-
|
|
182
|
-
@override
|
|
183
|
-
IntervalSet get label {
|
|
184
|
-
return IntervalSet.ofOne(atomLabel);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
@override
|
|
188
|
-
bool matches(int symbol, int minVocabSymbol, int maxVocabSymbol) {
|
|
189
|
-
return atomLabel == symbol;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
@override
|
|
193
|
-
String toString() {
|
|
194
|
-
return label.toString();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
@override
|
|
198
|
-
TransitionType get type => TransitionType.ATOM;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
class ActionTransition extends Transition {
|
|
202
|
-
final int ruleIndex;
|
|
203
|
-
final int actionIndex;
|
|
204
|
-
final bool isCtxDependent; // e.g., $i ref in pred
|
|
205
|
-
|
|
206
|
-
ActionTransition(target, this.ruleIndex,
|
|
207
|
-
[this.actionIndex = -1, this.isCtxDependent = false])
|
|
208
|
-
: super(target);
|
|
209
|
-
|
|
210
|
-
@override
|
|
211
|
-
bool get isEpsilon =>
|
|
212
|
-
true; // we are to be ignored by analysis 'cept for predicates
|
|
213
|
-
|
|
214
|
-
@override
|
|
215
|
-
bool matches(symbol, minVocabSymbol, maxVocabSymbol) => false;
|
|
216
|
-
|
|
217
|
-
@override
|
|
218
|
-
String toString() {
|
|
219
|
-
return 'action_$ruleIndex:$actionIndex';
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
@override
|
|
223
|
-
TransitionType get type => TransitionType.ACTION;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// A transition containing a set of values.
|
|
227
|
-
class SetTransition extends Transition {
|
|
228
|
-
@override
|
|
229
|
-
IntervalSet label;
|
|
230
|
-
|
|
231
|
-
SetTransition(ATNState target, [IntervalSet st]) : super(target) {
|
|
232
|
-
label = st ?? IntervalSet.ofOne(Token.INVALID_TYPE);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
@override
|
|
236
|
-
bool matches(symbol, minVocabSymbol, maxVocabSymbol) {
|
|
237
|
-
return label.contains(symbol);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@override
|
|
241
|
-
String toString() {
|
|
242
|
-
return label.toString();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
@override
|
|
246
|
-
TransitionType get type => TransitionType.SET;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
class NotSetTransition extends SetTransition {
|
|
250
|
-
NotSetTransition(target, st) : super(target, st);
|
|
251
|
-
|
|
252
|
-
@override
|
|
253
|
-
bool matches(symbol, minVocabSymbol, maxVocabSymbol) {
|
|
254
|
-
return symbol >= minVocabSymbol &&
|
|
255
|
-
symbol <= maxVocabSymbol &&
|
|
256
|
-
!super.matches(symbol, minVocabSymbol, maxVocabSymbol);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@override
|
|
260
|
-
String toString() {
|
|
261
|
-
return '~' + super.toString();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
@override
|
|
265
|
-
TransitionType get type => TransitionType.NOT_SET;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
class WildcardTransition extends Transition {
|
|
269
|
-
WildcardTransition(target) : super(target);
|
|
270
|
-
|
|
271
|
-
@override
|
|
272
|
-
bool matches(symbol, minVocabSymbol, maxVocabSymbol) {
|
|
273
|
-
return symbol >= minVocabSymbol && symbol <= maxVocabSymbol;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
@override
|
|
277
|
-
String toString() {
|
|
278
|
-
return '.';
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
@override
|
|
282
|
-
TransitionType get type => TransitionType.WILDCARD;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
class PrecedencePredicateTransition extends AbstractPredicateTransition {
|
|
286
|
-
final int precedence;
|
|
287
|
-
|
|
288
|
-
PrecedencePredicateTransition(target, this.precedence) : super(target);
|
|
289
|
-
|
|
290
|
-
@override
|
|
291
|
-
bool get isEpsilon => true;
|
|
292
|
-
|
|
293
|
-
@override
|
|
294
|
-
bool matches(symbol, minVocabSymbol, maxVocabSymbol) => false;
|
|
295
|
-
|
|
296
|
-
PrecedencePredicate get predicate {
|
|
297
|
-
return PrecedencePredicate(precedence);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
@override
|
|
301
|
-
String toString() => '$precedence >= _p';
|
|
302
|
-
|
|
303
|
-
@override
|
|
304
|
-
TransitionType get type => TransitionType.PRECEDENCE;
|
|
305
|
-
}
|
|
@@ -1,138 +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 '../../vocabulary.dart';
|
|
8
|
-
import '../../atn/atn.dart';
|
|
9
|
-
import 'dfa_serializer.dart';
|
|
10
|
-
import 'dfa_state.dart';
|
|
11
|
-
|
|
12
|
-
class DFA {
|
|
13
|
-
/// A set of all DFA states. Use [Map] so we can get old state back
|
|
14
|
-
/// ([Set] only allows you to see if it's there).
|
|
15
|
-
|
|
16
|
-
Map<DFAState, DFAState> states = {};
|
|
17
|
-
|
|
18
|
-
DFAState s0;
|
|
19
|
-
|
|
20
|
-
final int decision;
|
|
21
|
-
|
|
22
|
-
/// From which ATN state did we create this DFA? */
|
|
23
|
-
|
|
24
|
-
DecisionState atnStartState;
|
|
25
|
-
|
|
26
|
-
/// [true] if this DFA is for a precedence decision; otherwise,
|
|
27
|
-
/// [false]. This is the backing field for {@link #isPrecedenceDfa}.
|
|
28
|
-
bool precedenceDfa;
|
|
29
|
-
|
|
30
|
-
DFA(this.atnStartState, [this.decision]) {
|
|
31
|
-
var precedenceDfa = false;
|
|
32
|
-
if (atnStartState is StarLoopEntryState) {
|
|
33
|
-
if ((atnStartState as StarLoopEntryState).isPrecedenceDecision) {
|
|
34
|
-
precedenceDfa = true;
|
|
35
|
-
final precedenceState = DFAState(configs: ATNConfigSet());
|
|
36
|
-
precedenceState.edges = [];
|
|
37
|
-
precedenceState.isAcceptState = false;
|
|
38
|
-
precedenceState.requiresFullContext = false;
|
|
39
|
-
s0 = precedenceState;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
this.precedenceDfa = precedenceDfa;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/// Gets whether this DFA is a precedence DFA. Precedence DFAs use a special
|
|
47
|
-
/// start state {@link #s0} which is not stored in {@link #states}. The
|
|
48
|
-
/// {@link DFAState#edges} array for this start state contains outgoing edges
|
|
49
|
-
/// supplying individual start states corresponding to specific precedence
|
|
50
|
-
/// values.
|
|
51
|
-
///
|
|
52
|
-
/// @return [true] if this is a precedence DFA; otherwise,
|
|
53
|
-
/// [false].
|
|
54
|
-
/// @see Parser#getPrecedence()
|
|
55
|
-
bool isPrecedenceDfa() {
|
|
56
|
-
return precedenceDfa;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/// Get the start state for a specific precedence value.
|
|
60
|
-
///
|
|
61
|
-
/// @param precedence The current precedence.
|
|
62
|
-
/// @return The start state corresponding to the specified precedence, or
|
|
63
|
-
/// null if no start state exists for the specified precedence.
|
|
64
|
-
///
|
|
65
|
-
/// @throws IllegalStateException if this is not a precedence DFA.
|
|
66
|
-
/// @see #isPrecedenceDfa()
|
|
67
|
-
DFAState getPrecedenceStartState(int precedence) {
|
|
68
|
-
if (!isPrecedenceDfa()) {
|
|
69
|
-
throw StateError(
|
|
70
|
-
'Only precedence DFAs may contain a precedence start state.');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// s0.edges is never null for a precedence DFA
|
|
74
|
-
if (precedence < 0 || precedence >= s0.edges.length) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return s0.edges[precedence];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/// Set the start state for a specific precedence value.
|
|
82
|
-
///
|
|
83
|
-
/// @param precedence The current precedence.
|
|
84
|
-
/// @param startState The start state corresponding to the specified
|
|
85
|
-
/// precedence.
|
|
86
|
-
///
|
|
87
|
-
/// @throws IllegalStateException if this is not a precedence DFA.
|
|
88
|
-
/// @see #isPrecedenceDfa()
|
|
89
|
-
void setPrecedenceStartState(int precedence, DFAState startState) {
|
|
90
|
-
if (!isPrecedenceDfa()) {
|
|
91
|
-
throw StateError(
|
|
92
|
-
'Only precedence DFAs may contain a precedence start state.');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (precedence < 0) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// synchronization on s0 here is ok. when the DFA is turned into a
|
|
100
|
-
// precedence DFA, s0 will be initialized once and not updated again
|
|
101
|
-
// s0.edges is never null for a precedence DFA
|
|
102
|
-
if (precedence >= s0.edges.length) {
|
|
103
|
-
final original = s0.edges;
|
|
104
|
-
s0.edges = List(precedence + 1);
|
|
105
|
-
List.copyRange(s0.edges, 0, original);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
s0.edges[precedence] = startState;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/// Return a list of all states in this DFA, ordered by state number.
|
|
112
|
-
|
|
113
|
-
List<DFAState> getStates() {
|
|
114
|
-
final result = states.keys.toList();
|
|
115
|
-
result.sort((DFAState o1, DFAState o2) {
|
|
116
|
-
return o1.stateNumber - o2.stateNumber;
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
return result;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@override
|
|
123
|
-
String toString([Vocabulary vocabulary]) {
|
|
124
|
-
vocabulary = vocabulary ?? VocabularyImpl.EMPTY_VOCABULARY;
|
|
125
|
-
if (s0 == null) {
|
|
126
|
-
return '';
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
final serializer = DFASerializer(this, vocabulary);
|
|
130
|
-
return serializer.toString();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
String toLexerString() {
|
|
134
|
-
if (s0 == null) return '';
|
|
135
|
-
DFASerializer serializer = LexerDFASerializer(this);
|
|
136
|
-
return serializer.toString();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,76 +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 '../../util/utils.dart';
|
|
8
|
-
import '../../vocabulary.dart';
|
|
9
|
-
import 'dfa.dart';
|
|
10
|
-
import 'dfa_state.dart';
|
|
11
|
-
|
|
12
|
-
/// A DFA walker that knows how to dump them to serialized strings. */
|
|
13
|
-
class DFASerializer {
|
|
14
|
-
final DFA dfa;
|
|
15
|
-
|
|
16
|
-
final Vocabulary vocabulary;
|
|
17
|
-
|
|
18
|
-
DFASerializer(this.dfa, this.vocabulary);
|
|
19
|
-
|
|
20
|
-
@override
|
|
21
|
-
String toString() {
|
|
22
|
-
if (dfa.s0 == null) return null;
|
|
23
|
-
final buf = StringBuffer();
|
|
24
|
-
final states = dfa.getStates();
|
|
25
|
-
for (var s in states) {
|
|
26
|
-
var n = 0;
|
|
27
|
-
if (s.edges != null) n = s.edges.length;
|
|
28
|
-
for (var i = 0; i < n; i++) {
|
|
29
|
-
final t = s.edges[i];
|
|
30
|
-
if (t != null && t.stateNumber != 0x7FFFFFFF) {
|
|
31
|
-
buf.write(getStateString(s));
|
|
32
|
-
final label = getEdgeLabel(i);
|
|
33
|
-
buf.write('-');
|
|
34
|
-
buf.write(label);
|
|
35
|
-
buf.write('->');
|
|
36
|
-
buf.write(getStateString(t));
|
|
37
|
-
buf.write('\n');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
final output = buf.toString();
|
|
43
|
-
if (output.isEmpty) return null;
|
|
44
|
-
//return Utils.sortLinesInString(output);
|
|
45
|
-
return output;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
String getEdgeLabel(int i) {
|
|
49
|
-
return vocabulary.getDisplayName(i - 1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
String getStateString(DFAState s) {
|
|
53
|
-
final n = s.stateNumber;
|
|
54
|
-
final baseStateStr = (s.isAcceptState ? ':' : '') +
|
|
55
|
-
's$n' +
|
|
56
|
-
(s.requiresFullContext ? '^' : '');
|
|
57
|
-
if (s.isAcceptState) {
|
|
58
|
-
if (s.predicates != null) {
|
|
59
|
-
return baseStateStr + '=>${arrayToString(s.predicates)}';
|
|
60
|
-
} else {
|
|
61
|
-
return baseStateStr + '=>${s.prediction}';
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
return baseStateStr;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
class LexerDFASerializer extends DFASerializer {
|
|
70
|
-
LexerDFASerializer(dfa) : super(dfa, VocabularyImpl.EMPTY_VOCABULARY);
|
|
71
|
-
|
|
72
|
-
@override
|
|
73
|
-
String getEdgeLabel(i) {
|
|
74
|
-
return "'" + String.fromCharCode(i) + "'";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,151 +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 '../../util/murmur_hash.dart';
|
|
9
|
-
import '../../util/utils.dart';
|
|
10
|
-
|
|
11
|
-
/// Map a predicate to a predicted alternative. */
|
|
12
|
-
class PredPrediction {
|
|
13
|
-
final alt;
|
|
14
|
-
final pred;
|
|
15
|
-
|
|
16
|
-
PredPrediction(this.pred, this.alt);
|
|
17
|
-
|
|
18
|
-
@override
|
|
19
|
-
String toString() {
|
|
20
|
-
return '($pred, $alt)';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/// A DFA state represents a set of possible ATN configurations.
|
|
25
|
-
/// As Aho, Sethi, Ullman p. 117 says "The DFA uses its state
|
|
26
|
-
/// to keep track of all possible states the ATN can be in after
|
|
27
|
-
/// reading each input symbol. That is to say, after reading
|
|
28
|
-
/// input a1a2..an, the DFA is in a state that represents the
|
|
29
|
-
/// subset T of the states of the ATN that are reachable from the
|
|
30
|
-
/// ATN's start state along some path labeled a1a2..an."
|
|
31
|
-
/// In conventional NFA→DFA conversion, therefore, the subset T
|
|
32
|
-
/// would be a bitset representing the set of states the
|
|
33
|
-
/// ATN could be in. We need to track the alt predicted by each
|
|
34
|
-
/// state as well, however. More importantly, we need to maintain
|
|
35
|
-
/// a stack of states, tracking the closure operations as they
|
|
36
|
-
/// jump from rule to rule, emulating rule invocations (method calls).
|
|
37
|
-
/// I have to add a stack to simulate the proper lookahead sequences for
|
|
38
|
-
/// the underlying LL grammar from which the ATN was derived.
|
|
39
|
-
///
|
|
40
|
-
/// <p>I use a set of ATNConfig objects not simple states. An ATNConfig
|
|
41
|
-
/// is both a state (ala normal conversion) and a RuleContext describing
|
|
42
|
-
/// the chain of rules (if any) followed to arrive at that state.</p>
|
|
43
|
-
///
|
|
44
|
-
/// <p>A DFA state may have multiple references to a particular state,
|
|
45
|
-
/// but with different ATN contexts (with same or different alts)
|
|
46
|
-
/// meaning that state was reached via a different set of rule invocations.</p>
|
|
47
|
-
class DFAState {
|
|
48
|
-
int stateNumber = -1;
|
|
49
|
-
|
|
50
|
-
ATNConfigSet configs = ATNConfigSet();
|
|
51
|
-
|
|
52
|
-
/// {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1)
|
|
53
|
-
/// {@link Token#EOF} maps to {@code edges[0]}.
|
|
54
|
-
|
|
55
|
-
List<DFAState> edges;
|
|
56
|
-
|
|
57
|
-
bool isAcceptState = false;
|
|
58
|
-
|
|
59
|
-
/// if accept state, what ttype do we match or alt do we predict?
|
|
60
|
-
/// This is set to {@link ATN#INVALID_ALT_NUMBER} when {@link #predicates}{@code !=null} or
|
|
61
|
-
/// {@link #requiresFullContext}.
|
|
62
|
-
int prediction = 0;
|
|
63
|
-
|
|
64
|
-
LexerActionExecutor lexerActionExecutor;
|
|
65
|
-
|
|
66
|
-
/// Indicates that this state was created during SLL prediction that
|
|
67
|
-
/// discovered a conflict between the configurations in the state. Future
|
|
68
|
-
/// {@link ParserATNSimulator#execATN} invocations immediately jumped doing
|
|
69
|
-
/// full context prediction if this field is true.
|
|
70
|
-
bool requiresFullContext = false;
|
|
71
|
-
|
|
72
|
-
/// During SLL parsing, this is a list of predicates associated with the
|
|
73
|
-
/// ATN configurations of the DFA state. When we have predicates,
|
|
74
|
-
/// {@link #requiresFullContext} is [false] since full context prediction evaluates predicates
|
|
75
|
-
/// on-the-fly. If this is not null, then {@link #prediction} is
|
|
76
|
-
/// {@link ATN#INVALID_ALT_NUMBER}.
|
|
77
|
-
///
|
|
78
|
-
/// <p>We only use these for non-{@link #requiresFullContext} but conflicting states. That
|
|
79
|
-
/// means we know from the context (it's $ or we don't dip into outer
|
|
80
|
-
/// context) that it's an ambiguity not a conflict.</p>
|
|
81
|
-
///
|
|
82
|
-
/// <p>This list is computed by {@link ParserATNSimulator#predicateDFAState}.</p>
|
|
83
|
-
|
|
84
|
-
List<PredPrediction> predicates;
|
|
85
|
-
|
|
86
|
-
DFAState({this.stateNumber, this.configs});
|
|
87
|
-
|
|
88
|
-
/// Get the set of all alts mentioned by all ATN configurations in this
|
|
89
|
-
/// DFA state.
|
|
90
|
-
Set<int> get altSet {
|
|
91
|
-
final alts = <int>{};
|
|
92
|
-
if (configs != null) {
|
|
93
|
-
for (var c in configs) {
|
|
94
|
-
alts.add(c.alt);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (alts.isEmpty) return null;
|
|
98
|
-
return alts;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@override
|
|
102
|
-
int get hashCode {
|
|
103
|
-
var hash = MurmurHash.initialize(7);
|
|
104
|
-
hash = MurmurHash.update(hash, configs.hashCode);
|
|
105
|
-
hash = MurmurHash.finish(hash, 1);
|
|
106
|
-
return hash;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/// Two [DFAState] instances are equal if their ATN configuration sets
|
|
110
|
-
/// are the same. This method is used to see if a state already exists.
|
|
111
|
-
///
|
|
112
|
-
/// <p>Because the number of alternatives and number of ATN configurations are
|
|
113
|
-
/// finite, there is a finite number of DFA states that can be processed.
|
|
114
|
-
/// This is necessary to show that the algorithm terminates.</p>
|
|
115
|
-
///
|
|
116
|
-
/// <p>Cannot test the DFA state numbers here because in
|
|
117
|
-
/// {@link ParserATNSimulator#addDFAState} we need to know if any other state
|
|
118
|
-
/// exists that has this exact set of ATN configurations. The
|
|
119
|
-
/// {@link #stateNumber} is irrelevant.</p>
|
|
120
|
-
|
|
121
|
-
@override
|
|
122
|
-
bool operator ==(Object o) {
|
|
123
|
-
// compare set of ATN configurations in this set with other
|
|
124
|
-
if (identical(this, o)) return true;
|
|
125
|
-
|
|
126
|
-
if (!(o is DFAState)) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
DFAState other = o;
|
|
131
|
-
// TODO (sam): what to do when configs==null?
|
|
132
|
-
final sameSet = configs == other.configs;
|
|
133
|
-
// System.out.println("DFAState.equals: "+configs+(sameSet?"==":"!=")+other.configs);
|
|
134
|
-
return sameSet;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
@override
|
|
138
|
-
String toString() {
|
|
139
|
-
final buf = StringBuffer();
|
|
140
|
-
buf.write('$stateNumber:$configs');
|
|
141
|
-
if (isAcceptState) {
|
|
142
|
-
buf.write('=>');
|
|
143
|
-
if (predicates != null) {
|
|
144
|
-
buf.write(arrayToString(predicates));
|
|
145
|
-
} else {
|
|
146
|
-
buf.write(prediction);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return buf.toString();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,10 +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
|
-
export 'src/diagnostic_error_listener.dart';
|
|
8
|
-
export 'src/error_listener.dart';
|
|
9
|
-
export 'src/error_strategy.dart';
|
|
10
|
-
export 'src/errors.dart';
|