@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.
Files changed (158) hide show
  1. package/__tests__/end-to-end.test.ts +256 -0
  2. package/coverage/clover.xml +12857 -0
  3. package/coverage/coverage-final.json +3 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +79 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +126 -0
  8. package/coverage/lcov-report/index.js.html +104 -0
  9. package/coverage/lcov-report/out.js.html +41126 -0
  10. package/coverage/lcov-report/prettify.css +1 -0
  11. package/coverage/lcov-report/prettify.js +2 -0
  12. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  13. package/coverage/lcov-report/sorter.js +170 -0
  14. package/coverage/lcov.info +24801 -0
  15. package/index.d.ts +118 -0
  16. package/index.js +8 -0
  17. package/index.ts +141 -0
  18. package/jest.config.js +11 -0
  19. package/out.js +13708 -0
  20. package/package.json +22 -17
  21. package/tsconfig.json +5 -3
  22. package/.idea/apexdocs-dart.iml +0 -18
  23. package/.idea/jsLibraryMappings.xml +0 -6
  24. package/.idea/libraries/Dart_Packages.xml +0 -556
  25. package/.idea/libraries/Dart_SDK.xml +0 -28
  26. package/.idea/misc.xml +0 -6
  27. package/.idea/modules.xml +0 -8
  28. package/.idea/runConfigurations/_template__of_Dart_Test.xml +0 -6
  29. package/.idea/vcs.xml +0 -6
  30. package/CHANGELOG.md +0 -3
  31. package/README.md +0 -26
  32. package/TODO.md +0 -5
  33. package/analysis_options.yaml +0 -30
  34. package/antlr4-4.9.2/CHANGELOG.md +0 -4
  35. package/antlr4-4.9.2/LICENSE +0 -52
  36. package/antlr4-4.9.2/README.md +0 -11
  37. package/antlr4-4.9.2/analysis_options.yaml +0 -1
  38. package/antlr4-4.9.2/lib/antlr4.dart +0 -21
  39. package/antlr4-4.9.2/lib/src/atn/atn.dart +0 -18
  40. package/antlr4-4.9.2/lib/src/atn/src/atn.dart +0 -170
  41. package/antlr4-4.9.2/lib/src/atn/src/atn_config.dart +0 -242
  42. package/antlr4-4.9.2/lib/src/atn/src/atn_config_set.dart +0 -283
  43. package/antlr4-4.9.2/lib/src/atn/src/atn_deserializer.dart +0 -809
  44. package/antlr4-4.9.2/lib/src/atn/src/atn_simulator.dart +0 -95
  45. package/antlr4-4.9.2/lib/src/atn/src/atn_state.dart +0 -296
  46. package/antlr4-4.9.2/lib/src/atn/src/atn_type.dart +0 -14
  47. package/antlr4-4.9.2/lib/src/atn/src/info.dart +0 -553
  48. package/antlr4-4.9.2/lib/src/atn/src/lexer_action.dart +0 -601
  49. package/antlr4-4.9.2/lib/src/atn/src/lexer_action_executor.dart +0 -167
  50. package/antlr4-4.9.2/lib/src/atn/src/lexer_atn_simulator.dart +0 -731
  51. package/antlr4-4.9.2/lib/src/atn/src/parser_atn_simulator.dart +0 -2630
  52. package/antlr4-4.9.2/lib/src/atn/src/profiling_atn_simulator.dart +0 -229
  53. package/antlr4-4.9.2/lib/src/atn/src/semantic_context.dart +0 -404
  54. package/antlr4-4.9.2/lib/src/atn/src/transition.dart +0 -305
  55. package/antlr4-4.9.2/lib/src/dfa/dfa.dart +0 -8
  56. package/antlr4-4.9.2/lib/src/dfa/src/dfa.dart +0 -138
  57. package/antlr4-4.9.2/lib/src/dfa/src/dfa_serializer.dart +0 -76
  58. package/antlr4-4.9.2/lib/src/dfa/src/dfa_state.dart +0 -151
  59. package/antlr4-4.9.2/lib/src/error/error.dart +0 -10
  60. package/antlr4-4.9.2/lib/src/error/src/diagnostic_error_listener.dart +0 -116
  61. package/antlr4-4.9.2/lib/src/error/src/error_listener.dart +0 -241
  62. package/antlr4-4.9.2/lib/src/error/src/error_strategy.dart +0 -902
  63. package/antlr4-4.9.2/lib/src/error/src/errors.dart +0 -204
  64. package/antlr4-4.9.2/lib/src/input_stream.dart +0 -335
  65. package/antlr4-4.9.2/lib/src/interval_set.dart +0 -735
  66. package/antlr4-4.9.2/lib/src/lexer.dart +0 -343
  67. package/antlr4-4.9.2/lib/src/ll1_analyzer.dart +0 -204
  68. package/antlr4-4.9.2/lib/src/misc/multi_map.dart +0 -32
  69. package/antlr4-4.9.2/lib/src/misc/pair.dart +0 -34
  70. package/antlr4-4.9.2/lib/src/parser.dart +0 -777
  71. package/antlr4-4.9.2/lib/src/parser_interpreter.dart +0 -393
  72. package/antlr4-4.9.2/lib/src/parser_rule_context.dart +0 -275
  73. package/antlr4-4.9.2/lib/src/prediction_context.dart +0 -877
  74. package/antlr4-4.9.2/lib/src/recognizer.dart +0 -182
  75. package/antlr4-4.9.2/lib/src/rule_context.dart +0 -192
  76. package/antlr4-4.9.2/lib/src/runtime_meta_data.dart +0 -188
  77. package/antlr4-4.9.2/lib/src/token.dart +0 -431
  78. package/antlr4-4.9.2/lib/src/token_factory.dart +0 -88
  79. package/antlr4-4.9.2/lib/src/token_source.dart +0 -241
  80. package/antlr4-4.9.2/lib/src/token_stream.dart +0 -627
  81. package/antlr4-4.9.2/lib/src/tree/src/pattern/chunk.dart +0 -90
  82. package/antlr4-4.9.2/lib/src/tree/src/pattern/parse_tree_match.dart +0 -635
  83. package/antlr4-4.9.2/lib/src/tree/src/tree.dart +0 -370
  84. package/antlr4-4.9.2/lib/src/tree/src/trees.dart +0 -226
  85. package/antlr4-4.9.2/lib/src/tree/tree.dart +0 -10
  86. package/antlr4-4.9.2/lib/src/util/bit_set.dart +0 -308
  87. package/antlr4-4.9.2/lib/src/util/murmur_hash.dart +0 -77
  88. package/antlr4-4.9.2/lib/src/util/utils.dart +0 -31
  89. package/antlr4-4.9.2/lib/src/vocabulary.dart +0 -254
  90. package/antlr4-4.9.2/pubspec.yaml +0 -13
  91. package/example/node_example/index.js +0 -8
  92. package/example/node_example/package.json +0 -12
  93. package/example/node_example_ts/package-lock.json +0 -70
  94. package/example/node_example_ts/package.json +0 -19
  95. package/example/node_example_ts/src/index.js +0 -5
  96. package/example/node_example_ts/src/index.ts +0 -9
  97. package/example/node_example_ts/tsconfig.json +0 -79
  98. package/js/dart2jsout.js +0 -25898
  99. package/js/dart2jsout.js.map +0 -16
  100. package/js/index.d.ts +0 -1
  101. package/js/index.js +0 -4
  102. package/js/out.js +0 -26023
  103. package/js/out.js.map +0 -16
  104. package/js/package-lock.json +0 -57
  105. package/js/preamble.js +0 -125
  106. package/lib/apexdocs_dart.dart +0 -28
  107. package/lib/src/antlr/grammars/Apexdoc/ApexdocLexer.g4 +0 -120
  108. package/lib/src/antlr/grammars/Apexdoc/ApexdocParser.g4 +0 -158
  109. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.interp +0 -95
  110. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.java +0 -238
  111. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.tokens +0 -23
  112. package/lib/src/antlr/grammars/apex/ApexLexer.g4 +0 -255
  113. package/lib/src/antlr/grammars/apex/ApexParser.g4 +0 -567
  114. package/lib/src/antlr/grammars/apex/examples/ApexClass.cls +0 -6
  115. package/lib/src/antlr/lib/apex/ApexLexer.dart +0 -1223
  116. package/lib/src/antlr/lib/apex/ApexLexer.interp +0 -393
  117. package/lib/src/antlr/lib/apex/ApexLexer.tokens +0 -212
  118. package/lib/src/antlr/lib/apex/ApexParser.dart +0 -9349
  119. package/lib/src/antlr/lib/apex/ApexParser.interp +0 -326
  120. package/lib/src/antlr/lib/apex/ApexParser.tokens +0 -212
  121. package/lib/src/antlr/lib/apex/ApexParserBaseListener.dart +0 -1036
  122. package/lib/src/antlr/lib/apex/ApexParserListener.dart +0 -975
  123. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.dart +0 -373
  124. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.interp +0 -95
  125. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.tokens +0 -23
  126. package/lib/src/antlr/lib/apexdoc/ApexdocParser.dart +0 -2471
  127. package/lib/src/antlr/lib/apexdoc/ApexdocParser.interp +0 -69
  128. package/lib/src/antlr/lib/apexdoc/ApexdocParser.tokens +0 -23
  129. package/lib/src/antlr/lib/apexdoc/ApexdocParserBaseListener.dart +0 -252
  130. package/lib/src/antlr/lib/apexdoc/ApexdocParserListener.dart +0 -215
  131. package/lib/src/builders/builders.dart +0 -32
  132. package/lib/src/model/apex_file_manifest.dart +0 -37
  133. package/lib/src/model/apex_file_manifest.g.dart +0 -18
  134. package/lib/src/model/declaration.dart +0 -50
  135. package/lib/src/model/doc_comment.dart +0 -117
  136. package/lib/src/model/doc_comment.g.dart +0 -118
  137. package/lib/src/model/members.dart +0 -143
  138. package/lib/src/model/members.g.dart +0 -105
  139. package/lib/src/model/types.dart +0 -159
  140. package/lib/src/model/types.g.dart +0 -111
  141. package/lib/src/service/apex_listener.dart +0 -226
  142. package/lib/src/service/apexdoc_listener.dart +0 -82
  143. package/lib/src/service/parsers.dart +0 -33
  144. package/lib/src/service/utils/parsing/access_modifiers_parser.dart +0 -33
  145. package/lib/src/service/utils/parsing/parameters_parser.dart +0 -18
  146. package/lib/src/service/utils/parsing/parsing_utils.dart +0 -2
  147. package/lib/src/service/walker.dart +0 -82
  148. package/pubspec.yaml +0 -19
  149. package/test/apex_file_manifest_test.dart +0 -16
  150. package/test/apex_listener_test.dart +0 -703
  151. package/test/apexdoc_parser_test.dart +0 -179
  152. package/test/doc_comment_test.dart +0 -89
  153. package/test/members_serialization_test.dart +0 -158
  154. package/test/members_test.dart +0 -178
  155. package/test/types_serialization_test.dart +0 -191
  156. package/test/types_test.dart +0 -311
  157. package/test/walker_test.dart +0 -58
  158. package/tool/grind.dart +0 -20
@@ -1,553 +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 '../../token_stream.dart';
8
- import '../../util/bit_set.dart';
9
- import 'atn_config_set.dart';
10
- import 'profiling_atn_simulator.dart';
11
- import 'semantic_context.dart';
12
-
13
- /// This class represents profiling event information for a context sensitivity.
14
- /// Context sensitivities are decisions where a particular input resulted in an
15
- /// SLL conflict, but LL prediction produced a single unique alternative.
16
- ///
17
- /// <p>
18
- /// In some cases, the unique alternative identified by LL prediction is not
19
- /// equal to the minimum represented alternative in the conflicting SLL
20
- /// configuration set. Grammars and inputs which result in this scenario are
21
- /// unable to use {@link PredictionMode#SLL}, which in turn means they cannot use
22
- /// the two-stage parsing strategy to improve parsing performance for that
23
- /// input.</p>
24
- ///
25
- /// @see ParserATNSimulator#reportContextSensitivity
26
- /// @see ANTLRErrorListener#reportContextSensitivity
27
- ///
28
- /// @since 4.3
29
- class ContextSensitivityInfo extends DecisionEventInfo {
30
- /// Constructs a new instance of the [ContextSensitivityInfo] class
31
- /// with the specified detailed context sensitivity information.
32
- ///
33
- /// @param decision The decision number
34
- /// @param configs The final configuration set containing the unique
35
- /// alternative identified by full-context prediction
36
- /// @param input The input token stream
37
- /// @param startIndex The start index for the current prediction
38
- /// @param stopIndex The index at which the context sensitivity was
39
- /// identified during full-context prediction
40
- ContextSensitivityInfo(int decision, ATNConfigSet configs, TokenStream input,
41
- int startIndex, int stopIndex)
42
- : super(decision, configs, input, startIndex, stopIndex, true);
43
- }
44
-
45
- /// This is the base class for gathering detailed information about prediction
46
- /// events which occur during parsing.
47
- ///
48
- /// Note that we could record the parser call stack at the time this event
49
- /// occurred but in the presence of left recursive rules, the stack is kind of
50
- /// meaningless. It's better to look at the individual configurations for their
51
- /// individual stacks. Of course that is a [PredictionContext] object
52
- /// not a parse tree node and so it does not have information about the extent
53
- /// (start...stop) of the various subtrees. Examining the stack tops of all
54
- /// configurations provide the return states for the rule invocations.
55
- /// From there you can get the enclosing rule.
56
- ///
57
- /// @since 4.3
58
- class DecisionEventInfo {
59
- /// The invoked decision number which this event is related to.
60
- ///
61
- /// @see ATN#decisionToState
62
- final int decision;
63
-
64
- /// The configuration set containing additional information relevant to the
65
- /// prediction state when the current event occurred, or null if no
66
- /// additional information is relevant or available.
67
- final ATNConfigSet configs;
68
-
69
- /// The input token stream which is being parsed.
70
- final TokenStream input;
71
-
72
- /// The token index in the input stream at which the current prediction was
73
- /// originally invoked.
74
- final int startIndex;
75
-
76
- /// The token index in the input stream at which the current event occurred.
77
- final int stopIndex;
78
-
79
- /// [true] if the current event occurred during LL prediction;
80
- /// otherwise, [false] if the input occurred during SLL prediction.
81
- final bool fullCtx;
82
-
83
- DecisionEventInfo(this.decision, this.configs, this.input, this.startIndex,
84
- this.stopIndex, this.fullCtx);
85
- }
86
-
87
- /// This class contains profiling gathered for a particular decision.
88
- ///
89
- /// <p>
90
- /// Parsing performance in ANTLR 4 is heavily influenced by both static factors
91
- /// (e.g. the form of the rules in the grammar) and dynamic factors (e.g. the
92
- /// choice of input and the state of the DFA cache at the time profiling
93
- /// operations are started). For best results, gather and use aggregate
94
- /// statistics from a large sample of inputs representing the inputs expected in
95
- /// production before using the results to make changes in the grammar.</p>
96
- ///
97
- /// @since 4.3
98
- class DecisionInfo {
99
- /// The decision number, which is an index into {@link ATN#decisionToState}.
100
- final int decision;
101
-
102
- /// The total number of times {@link ParserATNSimulator#adaptivePredict} was
103
- /// invoked for this decision.
104
- int invocations;
105
-
106
- /// The total time spent in {@link ParserATNSimulator#adaptivePredict} for
107
- /// this decision, in nanoseconds.
108
- ///
109
- /// <p>
110
- /// The value of this field contains the sum of differential results obtained
111
- /// by {@link System#nanoTime()}, and is not adjusted to compensate for JIT
112
- /// and/or garbage collection overhead. For best accuracy, use a modern JVM
113
- /// implementation that provides precise results from
114
- /// {@link System#nanoTime()}, and perform profiling in a separate process
115
- /// which is warmed up by parsing the input prior to profiling. If desired,
116
- /// call {@link ATNSimulator#clearDFA} to reset the DFA cache to its initial
117
- /// state before starting the profiling measurement pass.</p>
118
- int timeInPrediction;
119
-
120
- /// The sum of the lookahead required for SLL prediction for this decision.
121
- /// Note that SLL prediction is used before LL prediction for performance
122
- /// reasons even when {@link PredictionMode#LL} or
123
- /// {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} is used.
124
- int SLL_TotalLook;
125
-
126
- /// Gets the minimum lookahead required for any single SLL prediction to
127
- /// complete for this decision, by reaching a unique prediction, reaching an
128
- /// SLL conflict state, or encountering a syntax error.
129
- int SLL_MinLook;
130
-
131
- /// Gets the maximum lookahead required for any single SLL prediction to
132
- /// complete for this decision, by reaching a unique prediction, reaching an
133
- /// SLL conflict state, or encountering a syntax error.
134
- int SLL_MaxLook;
135
-
136
- /// Gets the [LookaheadEventInfo] associated with the event where the
137
- /// {@link #SLL_MaxLook} value was set.
138
- LookaheadEventInfo SLL_MaxLookEvent;
139
-
140
- /// The sum of the lookahead required for LL prediction for this decision.
141
- /// Note that LL prediction is only used when SLL prediction reaches a
142
- /// conflict state.
143
- int LL_TotalLook;
144
-
145
- /// Gets the minimum lookahead required for any single LL prediction to
146
- /// complete for this decision. An LL prediction completes when the algorithm
147
- /// reaches a unique prediction, a conflict state (for
148
- /// {@link PredictionMode#LL}, an ambiguity state (for
149
- /// {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
150
- int LL_MinLook;
151
-
152
- /// Gets the maximum lookahead required for any single LL prediction to
153
- /// complete for this decision. An LL prediction completes when the algorithm
154
- /// reaches a unique prediction, a conflict state (for
155
- /// {@link PredictionMode#LL}, an ambiguity state (for
156
- /// {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
157
- int LL_MaxLook;
158
-
159
- /// Gets the [LookaheadEventInfo] associated with the event where the
160
- /// {@link #LL_MaxLook} value was set.
161
- LookaheadEventInfo LL_MaxLookEvent;
162
-
163
- /// A collection of [ContextSensitivityInfo] instances describing the
164
- /// context sensitivities encountered during LL prediction for this decision.
165
- ///
166
- /// @see ContextSensitivityInfo
167
- final List<ContextSensitivityInfo> contextSensitivities = [];
168
-
169
- /// A collection of [ErrorInfo] instances describing the parse errors
170
- /// identified during calls to {@link ParserATNSimulator#adaptivePredict} for
171
- /// this decision.
172
- ///
173
- /// @see ErrorInfo
174
- final List<ErrorInfo> errors = [];
175
-
176
- /// A collection of [AmbiguityInfo] instances describing the
177
- /// ambiguities encountered during LL prediction for this decision.
178
- ///
179
- /// @see AmbiguityInfo
180
- final List<AmbiguityInfo> ambiguities = [];
181
-
182
- /// A collection of [PredicateEvalInfo] instances describing the
183
- /// results of evaluating individual predicates during prediction for this
184
- /// decision.
185
- ///
186
- /// @see PredicateEvalInfo
187
- final List<PredicateEvalInfo> predicateEvals = [];
188
-
189
- /// The total number of ATN transitions required during SLL prediction for
190
- /// this decision. An ATN transition is determined by the number of times the
191
- /// DFA does not contain an edge that is required for prediction, resulting
192
- /// in on-the-fly computation of that edge.
193
- ///
194
- /// <p>
195
- /// If DFA caching of SLL transitions is employed by the implementation, ATN
196
- /// computation may cache the computed edge for efficient lookup during
197
- /// future parsing of this decision. Otherwise, the SLL parsing algorithm
198
- /// will use ATN transitions exclusively.</p>
199
- ///
200
- /// @see #SLL_ATNTransitions
201
- /// @see ParserATNSimulator#computeTargetState
202
- /// @see LexerATNSimulator#computeTargetState
203
- int SLL_ATNTransitions;
204
-
205
- /// The total number of DFA transitions required during SLL prediction for
206
- /// this decision.
207
- ///
208
- /// <p>If the ATN simulator implementation does not use DFA caching for SLL
209
- /// transitions, this value will be 0.</p>
210
- ///
211
- /// @see ParserATNSimulator#getExistingTargetState
212
- /// @see LexerATNSimulator#getExistingTargetState
213
- int SLL_DFATransitions;
214
-
215
- /// Gets the total number of times SLL prediction completed in a conflict
216
- /// state, resulting in fallback to LL prediction.
217
- ///
218
- /// <p>Note that this value is not related to whether or not
219
- /// {@link PredictionMode#SLL} may be used successfully with a particular
220
- /// grammar. If the ambiguity resolution algorithm applied to the SLL
221
- /// conflicts for this decision produce the same result as LL prediction for
222
- /// this decision, {@link PredictionMode#SLL} would produce the same overall
223
- /// parsing result as {@link PredictionMode#LL}.</p>
224
- int LL_Fallback;
225
-
226
- /// The total number of ATN transitions required during LL prediction for
227
- /// this decision. An ATN transition is determined by the number of times the
228
- /// DFA does not contain an edge that is required for prediction, resulting
229
- /// in on-the-fly computation of that edge.
230
- ///
231
- /// <p>
232
- /// If DFA caching of LL transitions is employed by the implementation, ATN
233
- /// computation may cache the computed edge for efficient lookup during
234
- /// future parsing of this decision. Otherwise, the LL parsing algorithm will
235
- /// use ATN transitions exclusively.</p>
236
- ///
237
- /// @see #LL_DFATransitions
238
- /// @see ParserATNSimulator#computeTargetState
239
- /// @see LexerATNSimulator#computeTargetState
240
- int LL_ATNTransitions;
241
-
242
- /// The total number of DFA transitions required during LL prediction for
243
- /// this decision.
244
- ///
245
- /// <p>If the ATN simulator implementation does not use DFA caching for LL
246
- /// transitions, this value will be 0.</p>
247
- ///
248
- /// @see ParserATNSimulator#getExistingTargetState
249
- /// @see LexerATNSimulator#getExistingTargetState
250
- int LL_DFATransitions;
251
-
252
- /// Constructs a new instance of the [DecisionInfo] class to contain
253
- /// statistics for a particular decision.
254
- ///
255
- /// @param decision The decision number
256
- DecisionInfo(this.decision);
257
-
258
- @override
259
- String toString() {
260
- return '{'
261
- 'decision=$decision'
262
- ', contextSensitivities=${contextSensitivities.length}'
263
- ', errors=${errors.length}'
264
- ', ambiguities=${ambiguities.length}'
265
- ', SLL_lookahead=$SLL_TotalLook'
266
- ', SLL_ATNTransitions=$SLL_ATNTransitions, SLL_DFATransitions=$SLL_DFATransitions, LL_Fallback=$LL_Fallback, LL_lookahead=$LL_TotalLook, LL_ATNTransitions=$LL_ATNTransitions}';
267
- }
268
- }
269
-
270
- /// This class represents profiling event information for an ambiguity.
271
- /// Ambiguities are decisions where a particular input resulted in an SLL
272
- /// conflict, followed by LL prediction also reaching a conflict state
273
- /// (indicating a true ambiguity in the grammar).
274
- ///
275
- /// <p>
276
- /// This event may be reported during SLL prediction in cases where the
277
- /// conflicting SLL configuration set provides sufficient information to
278
- /// determine that the SLL conflict is truly an ambiguity. For example, if none
279
- /// of the ATN configurations in the conflicting SLL configuration set have
280
- /// traversed a global follow transition (i.e.
281
- /// {@link ATNConfig#reachesIntoOuterContext} is 0 for all configurations), then
282
- /// the result of SLL prediction for that input is known to be equivalent to the
283
- /// result of LL prediction for that input.</p>
284
- ///
285
- /// <p>
286
- /// In some cases, the minimum represented alternative in the conflicting LL
287
- /// configuration set is not equal to the minimum represented alternative in the
288
- /// conflicting SLL configuration set. Grammars and inputs which result in this
289
- /// scenario are unable to use {@link PredictionMode#SLL}, which in turn means
290
- /// they cannot use the two-stage parsing strategy to improve parsing performance
291
- /// for that input.</p>
292
- ///
293
- /// @see ParserATNSimulator#reportAmbiguity
294
- /// @see ANTLRErrorListener#reportAmbiguity
295
- ///
296
- /// @since 4.3
297
- class AmbiguityInfo extends DecisionEventInfo {
298
- /// The set of alternative numbers for this decision event that lead to a valid parse. */
299
- BitSet ambigAlts;
300
-
301
- /// Constructs a new instance of the [AmbiguityInfo] class with the
302
- /// specified detailed ambiguity information.
303
- ///
304
- /// @param decision The decision number
305
- /// @param configs The final configuration set identifying the ambiguous
306
- /// alternatives for the current input
307
- /// @param ambigAlts The set of alternatives in the decision that lead to a valid parse.
308
- /// The predicted alt is the min(ambigAlts)
309
- /// @param input The input token stream
310
- /// @param startIndex The start index for the current prediction
311
- /// @param stopIndex The index at which the ambiguity was identified during
312
- /// prediction
313
- /// @param fullCtx [true] if the ambiguity was identified during LL
314
- /// prediction; otherwise, [false] if the ambiguity was identified
315
- /// during SLL prediction
316
- AmbiguityInfo(int decision, ATNConfigSet configs, this.ambigAlts,
317
- TokenStream input, int startIndex, int stopIndex, bool fullCtx)
318
- : super(decision, configs, input, startIndex, stopIndex, fullCtx);
319
- }
320
-
321
- /// This class represents profiling event information for a syntax error
322
- /// identified during prediction. Syntax errors occur when the prediction
323
- /// algorithm is unable to identify an alternative which would lead to a
324
- /// successful parse.
325
- ///
326
- /// @see Parser#notifyErrorListeners(Token, String, RecognitionException)
327
- /// @see ANTLRErrorListener#syntaxError
328
- ///
329
- /// @since 4.3
330
- class ErrorInfo extends DecisionEventInfo {
331
- /// Constructs a new instance of the [ErrorInfo] class with the
332
- /// specified detailed syntax error information.
333
- ///
334
- /// @param decision The decision number
335
- /// @param configs The final configuration set reached during prediction
336
- /// prior to reaching the {@link ATNSimulator#ERROR} state
337
- /// @param input The input token stream
338
- /// @param startIndex The start index for the current prediction
339
- /// @param stopIndex The index at which the syntax error was identified
340
- /// @param fullCtx [true] if the syntax error was identified during LL
341
- /// prediction; otherwise, [false] if the syntax error was identified
342
- /// during SLL prediction
343
- ErrorInfo(int decision, ATNConfigSet configs, TokenStream input,
344
- int startIndex, int stopIndex, bool fullCtx)
345
- : super(decision, configs, input, startIndex, stopIndex, fullCtx);
346
- }
347
-
348
- /// This class represents profiling event information for tracking the lookahead
349
- /// depth required in order to make a prediction.
350
- ///
351
- /// @since 4.3
352
- class LookaheadEventInfo extends DecisionEventInfo {
353
- /// The alternative chosen by adaptivePredict(), not necessarily
354
- /// the outermost alt shown for a rule; left-recursive rules have
355
- /// user-level alts that differ from the rewritten rule with a (...) block
356
- /// and a (..)* loop.
357
- int predictedAlt;
358
-
359
- /// Constructs a new instance of the [LookaheadEventInfo] class with
360
- /// the specified detailed lookahead information.
361
- ///
362
- /// @param decision The decision number
363
- /// @param configs The final configuration set containing the necessary
364
- /// information to determine the result of a prediction, or null if
365
- /// the final configuration set is not available
366
- /// @param input The input token stream
367
- /// @param startIndex The start index for the current prediction
368
- /// @param stopIndex The index at which the prediction was finally made
369
- /// @param fullCtx [true] if the current lookahead is part of an LL
370
- /// prediction; otherwise, [false] if the current lookahead is part of
371
- /// an SLL prediction
372
- LookaheadEventInfo(int decision, ATNConfigSet configs, this.predictedAlt,
373
- TokenStream input, int startIndex, int stopIndex, bool fullCtx)
374
- : super(decision, configs, input, startIndex, stopIndex, fullCtx);
375
- }
376
-
377
- /// This class represents profiling event information for semantic predicate
378
- /// evaluations which occur during prediction.
379
- ///
380
- /// @see ParserATNSimulator#evalSemanticContext
381
- ///
382
- /// @since 4.3
383
- class PredicateEvalInfo extends DecisionEventInfo {
384
- /// The semantic context which was evaluated.
385
- final SemanticContext semctx;
386
-
387
- /// The alternative number for the decision which is guarded by the semantic
388
- /// context {@link #semctx}. Note that other ATN
389
- /// configurations may predict the same alternative which are guarded by
390
- /// other semantic contexts and/or {@link SemanticContext#NONE}.
391
- final int predictedAlt;
392
-
393
- /// The result of evaluating the semantic context {@link #semctx}.
394
- final bool evalResult;
395
-
396
- /// Constructs a new instance of the [PredicateEvalInfo] class with the
397
- /// specified detailed predicate evaluation information.
398
- ///
399
- /// @param decision The decision number
400
- /// @param input The input token stream
401
- /// @param startIndex The start index for the current prediction
402
- /// @param stopIndex The index at which the predicate evaluation was
403
- /// triggered. Note that the input stream may be reset to other positions for
404
- /// the actual evaluation of individual predicates.
405
- /// @param semctx The semantic context which was evaluated
406
- /// @param evalResult The results of evaluating the semantic context
407
- /// @param predictedAlt The alternative number for the decision which is
408
- /// guarded by the semantic context [semctx]. See {@link #predictedAlt}
409
- /// for more information.
410
- /// @param fullCtx [true] if the semantic context was
411
- /// evaluated during LL prediction; otherwise, [false] if the semantic
412
- /// context was evaluated during SLL prediction
413
- ///
414
- /// @see ParserATNSimulator#evalSemanticContext(SemanticContext, ParserRuleContext, int, boolean)
415
- /// @see SemanticContext#eval(Recognizer, RuleContext)
416
- PredicateEvalInfo(
417
- int decision,
418
- TokenStream input,
419
- int startIndex,
420
- int stopIndex,
421
- this.semctx,
422
- this.evalResult,
423
- this.predictedAlt,
424
- bool fullCtx)
425
- : super(decision, ATNConfigSet(), input, startIndex, stopIndex, fullCtx);
426
- }
427
-
428
- /// This class provides access to specific and aggregate statistics gathered
429
- /// during profiling of a parser.
430
- ///
431
- /// @since 4.3
432
- class ParseInfo {
433
- final ProfilingATNSimulator atnSimulator;
434
-
435
- ParseInfo(this.atnSimulator);
436
-
437
- /// Gets an array of [DecisionInfo] instances containing the profiling
438
- /// information gathered for each decision in the ATN.
439
- ///
440
- /// @return An array of [DecisionInfo] instances, indexed by decision
441
- /// number.
442
- List<DecisionInfo> get decisionInfo {
443
- return atnSimulator.decisionInfo;
444
- }
445
-
446
- /// Gets the decision numbers for decisions that required one or more
447
- /// full-context predictions during parsing. These are decisions for which
448
- /// {@link DecisionInfo#LL_Fallback} is non-zero.
449
- ///
450
- /// @return A list of decision numbers which required one or more
451
- /// full-context predictions during parsing.
452
- List<int> get llDecisions {
453
- final decisions = atnSimulator.decisionInfo;
454
- final LL = <int>[];
455
- for (var i = 0; i < decisions.length; i++) {
456
- final fallBack = decisions[i].LL_Fallback;
457
- if (fallBack > 0) LL.add(i);
458
- }
459
- return LL;
460
- }
461
-
462
- /// Gets the total time spent during prediction across all decisions made
463
- /// during parsing. This value is the sum of
464
- /// {@link DecisionInfo#timeInPrediction} for all decisions.
465
- int get totalTimeInPrediction {
466
- final decisions = atnSimulator.decisionInfo;
467
- var t = 0;
468
- for (var i = 0; i < decisions.length; i++) {
469
- t += decisions[i].timeInPrediction;
470
- }
471
- return t;
472
- }
473
-
474
- /// Gets the total number of SLL lookahead operations across all decisions
475
- /// made during parsing. This value is the sum of
476
- /// {@link DecisionInfo#SLL_TotalLook} for all decisions.
477
- int get totalSLLLookaheadOps {
478
- final decisions = atnSimulator.decisionInfo;
479
- var k = 0;
480
- for (var i = 0; i < decisions.length; i++) {
481
- k += decisions[i].SLL_TotalLook;
482
- }
483
- return k;
484
- }
485
-
486
- /// Gets the total number of LL lookahead operations across all decisions
487
- /// made during parsing. This value is the sum of
488
- /// {@link DecisionInfo#LL_TotalLook} for all decisions.
489
- int get totalLLLookaheadOps {
490
- final decisions = atnSimulator.decisionInfo;
491
- var k = 0;
492
- for (var i = 0; i < decisions.length; i++) {
493
- k += decisions[i].LL_TotalLook;
494
- }
495
- return k;
496
- }
497
-
498
- /// Gets the total number of ATN lookahead operations for SLL prediction
499
- /// across all decisions made during parsing.
500
- int get totalSLLATNLookaheadOps {
501
- final decisions = atnSimulator.decisionInfo;
502
- var k = 0;
503
- for (var i = 0; i < decisions.length; i++) {
504
- k += decisions[i].SLL_ATNTransitions;
505
- }
506
- return k;
507
- }
508
-
509
- /// Gets the total number of ATN lookahead operations for LL prediction
510
- /// across all decisions made during parsing.
511
- int get totalLLATNLookaheadOps {
512
- final decisions = atnSimulator.decisionInfo;
513
- var k = 0;
514
- for (var i = 0; i < decisions.length; i++) {
515
- k += decisions[i].LL_ATNTransitions;
516
- }
517
- return k;
518
- }
519
-
520
- /// Gets the total number of ATN lookahead operations for SLL and LL
521
- /// prediction across all decisions made during parsing.
522
- ///
523
- /// <p>
524
- /// This value is the sum of {@link #getTotalSLLATNLookaheadOps} and
525
- /// {@link #getTotalLLATNLookaheadOps}.</p>
526
- int get totalATNLookaheadOps {
527
- final decisions = atnSimulator.decisionInfo;
528
- var k = 0;
529
- for (var i = 0; i < decisions.length; i++) {
530
- k += decisions[i].SLL_ATNTransitions;
531
- k += decisions[i].LL_ATNTransitions;
532
- }
533
- return k;
534
- }
535
-
536
- /// Gets the total number of DFA states stored in the DFA cache for all
537
- /// decisions in the ATN.
538
- int get dfaSize {
539
- var n = 0;
540
- final decisionToDFA = atnSimulator.decisionToDFA;
541
- for (var i = 0; i < decisionToDFA.length; i++) {
542
- n += getDFASizeAt(i);
543
- }
544
- return n;
545
- }
546
-
547
- /// Gets the total number of DFA states stored in the DFA cache for a
548
- /// particular decision.
549
- int getDFASizeAt(int decision) {
550
- final decisionToDFA = atnSimulator.decisionToDFA[decision];
551
- return decisionToDFA.states.length;
552
- }
553
- }