@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,731 +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:developer';
|
|
8
|
-
|
|
9
|
-
import 'package:logging/logging.dart';
|
|
10
|
-
|
|
11
|
-
import '../../dfa/dfa.dart';
|
|
12
|
-
import '../../error/error.dart';
|
|
13
|
-
import '../../input_stream.dart';
|
|
14
|
-
import '../../interval_set.dart';
|
|
15
|
-
import '../../lexer.dart';
|
|
16
|
-
import '../../prediction_context.dart';
|
|
17
|
-
import '../../token.dart';
|
|
18
|
-
import 'atn.dart';
|
|
19
|
-
import 'atn_config.dart';
|
|
20
|
-
import 'atn_config_set.dart';
|
|
21
|
-
import 'atn_simulator.dart';
|
|
22
|
-
import 'atn_state.dart';
|
|
23
|
-
import 'lexer_action_executor.dart';
|
|
24
|
-
import 'transition.dart';
|
|
25
|
-
|
|
26
|
-
/// When we hit an accept state in either the DFA or the ATN, we
|
|
27
|
-
/// have to notify the character stream to start buffering characters
|
|
28
|
-
/// via {@link IntStream#mark} and record the current state. The current sim state
|
|
29
|
-
/// includes the current index into the input, the current line,
|
|
30
|
-
/// and current character position in that line. Note that the Lexer is
|
|
31
|
-
/// tracking the starting line and characterization of the token. These
|
|
32
|
-
/// variables track the "state" of the simulator when it hits an accept state.
|
|
33
|
-
///
|
|
34
|
-
/// <p>We track these variables separately for the DFA and ATN simulation
|
|
35
|
-
/// because the DFA simulation often has to fail over to the ATN
|
|
36
|
-
/// simulation. If the ATN simulation fails, we need the DFA to fall
|
|
37
|
-
/// back to its previously accepted state, if any. If the ATN succeeds,
|
|
38
|
-
/// then the ATN does the accept and the DFA simulator that invoked it
|
|
39
|
-
/// can simply return the predicted token type.</p>
|
|
40
|
-
class SimState {
|
|
41
|
-
int index = -1;
|
|
42
|
-
int line = 0;
|
|
43
|
-
int charPos = -1;
|
|
44
|
-
|
|
45
|
-
DFAState dfaState;
|
|
46
|
-
|
|
47
|
-
void reset() {
|
|
48
|
-
index = -1;
|
|
49
|
-
line = 0;
|
|
50
|
-
charPos = -1;
|
|
51
|
-
dfaState = null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/// "dup" of ParserInterpreter */
|
|
56
|
-
class LexerATNSimulator extends ATNSimulator {
|
|
57
|
-
static final bool debug = true;
|
|
58
|
-
static final bool dfa_debug = true;
|
|
59
|
-
|
|
60
|
-
static final int MIN_DFA_EDGE = 0;
|
|
61
|
-
static final int MAX_DFA_EDGE = 127; // forces unicode to stay in ATN
|
|
62
|
-
|
|
63
|
-
final Lexer recog;
|
|
64
|
-
|
|
65
|
-
/// The current token's starting index into the character stream.
|
|
66
|
-
/// Shared across DFA to ATN simulation in case the ATN fails and the
|
|
67
|
-
/// DFA did not have a previous accept state. In this case, we use the
|
|
68
|
-
/// ATN-generated exception object.
|
|
69
|
-
int startIndex = -1;
|
|
70
|
-
|
|
71
|
-
/// line number 1..n within the input */
|
|
72
|
-
int line = 1;
|
|
73
|
-
|
|
74
|
-
/// The index of the character relative to the beginning of the line 0..n-1 */
|
|
75
|
-
int charPositionInLine = 0;
|
|
76
|
-
|
|
77
|
-
List<DFA> decisionToDFA;
|
|
78
|
-
int mode = Lexer.DEFAULT_MODE;
|
|
79
|
-
|
|
80
|
-
/// Used during DFA/ATN exec to record the most recent accept configuration info */
|
|
81
|
-
|
|
82
|
-
final SimState prevAccept = SimState();
|
|
83
|
-
|
|
84
|
-
LexerATNSimulator(ATN atn, this.decisionToDFA,
|
|
85
|
-
PredictionContextCache sharedContextCache,
|
|
86
|
-
{this.recog})
|
|
87
|
-
: super(atn, sharedContextCache);
|
|
88
|
-
|
|
89
|
-
void copyState(LexerATNSimulator simulator) {
|
|
90
|
-
charPositionInLine = simulator.charPositionInLine;
|
|
91
|
-
line = simulator.line;
|
|
92
|
-
mode = simulator.mode;
|
|
93
|
-
startIndex = simulator.startIndex;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
int match(CharStream input, int mode) {
|
|
97
|
-
this.mode = mode;
|
|
98
|
-
final mark = input.mark();
|
|
99
|
-
try {
|
|
100
|
-
startIndex = input.index;
|
|
101
|
-
prevAccept.reset();
|
|
102
|
-
final dfa = decisionToDFA[mode];
|
|
103
|
-
if (dfa.s0 == null) {
|
|
104
|
-
return matchATN(input);
|
|
105
|
-
} else {
|
|
106
|
-
return execATN(input, dfa.s0);
|
|
107
|
-
}
|
|
108
|
-
} finally {
|
|
109
|
-
input.release(mark);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
@override
|
|
114
|
-
void reset() {
|
|
115
|
-
prevAccept.reset();
|
|
116
|
-
startIndex = -1;
|
|
117
|
-
line = 1;
|
|
118
|
-
charPositionInLine = 0;
|
|
119
|
-
mode = Lexer.DEFAULT_MODE;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@override
|
|
123
|
-
void clearDFA() {
|
|
124
|
-
for (var d = 0; d < decisionToDFA.length; d++) {
|
|
125
|
-
decisionToDFA[d] = DFA(atn.getDecisionState(d), d);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
int matchATN(CharStream input) {
|
|
130
|
-
ATNState startState = atn.modeToStartState[mode];
|
|
131
|
-
|
|
132
|
-
if (debug) {
|
|
133
|
-
log('matchATN mode $mode start: $startState\n', level: Level.FINE.value);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
final old_mode = mode;
|
|
137
|
-
|
|
138
|
-
final s0_closure = computeStartState(input, startState);
|
|
139
|
-
final suppressEdge = s0_closure.hasSemanticContext;
|
|
140
|
-
s0_closure.hasSemanticContext = false;
|
|
141
|
-
|
|
142
|
-
final next = addDFAState(s0_closure);
|
|
143
|
-
if (!suppressEdge) {
|
|
144
|
-
decisionToDFA[mode].s0 = next;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
final predict = execATN(input, next);
|
|
148
|
-
|
|
149
|
-
if (debug) {
|
|
150
|
-
log('DFA after matchATN: ${decisionToDFA[old_mode].toLexerString()}\n',
|
|
151
|
-
level: Level.FINE.value);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return predict;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
int execATN(CharStream input, DFAState ds0) {
|
|
158
|
-
//log("enter exec index "+input.index()+" from "+ds0.configs, level: Level.FINE.value);
|
|
159
|
-
if (debug) {
|
|
160
|
-
log('start state closure=${ds0.configs}\n', level: Level.FINE.value);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (ds0.isAcceptState) {
|
|
164
|
-
// allow zero-length tokens
|
|
165
|
-
captureSimState(prevAccept, input, ds0);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
var t = input.LA(1);
|
|
169
|
-
|
|
170
|
-
var s = ds0; // s is current/from DFA state
|
|
171
|
-
|
|
172
|
-
while (true) {
|
|
173
|
-
// while more work
|
|
174
|
-
if (debug) {
|
|
175
|
-
log('execATN loop starting closure: ${s.configs}\n',
|
|
176
|
-
level: Level.FINE.value);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// As we move src->trg, src->trg, we keep track of the previous trg to
|
|
180
|
-
// avoid looking up the DFA state again, which is expensive.
|
|
181
|
-
// If the previous target was already part of the DFA, we might
|
|
182
|
-
// be able to avoid doing a reach operation upon t. If s!=null,
|
|
183
|
-
// it means that semantic predicates didn't prevent us from
|
|
184
|
-
// creating a DFA state. Once we know s!=null, we check to see if
|
|
185
|
-
// the DFA state has an edge already for t. If so, we can just reuse
|
|
186
|
-
// it's configuration set; there's no point in re-computing it.
|
|
187
|
-
// This is kind of like doing DFA simulation within the ATN
|
|
188
|
-
// simulation because DFA simulation is really just a way to avoid
|
|
189
|
-
// computing reach/closure sets. Technically, once we know that
|
|
190
|
-
// we have a previously added DFA state, we could jump over to
|
|
191
|
-
// the DFA simulator. But, that would mean popping back and forth
|
|
192
|
-
// a lot and making things more complicated algorithmically.
|
|
193
|
-
// This optimization makes a lot of sense for loops within DFA.
|
|
194
|
-
// A character will take us back to an existing DFA state
|
|
195
|
-
// that already has lots of edges out of it. e.g., .* in comments.
|
|
196
|
-
var target = getExistingTargetState(s, t);
|
|
197
|
-
target ??= computeTargetState(input, s, t);
|
|
198
|
-
|
|
199
|
-
if (target == ATNSimulator.ERROR) {
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// If this is a consumable input element, make sure to consume before
|
|
204
|
-
// capturing the accept state so the input index, line, and char
|
|
205
|
-
// position accurately reflect the state of the interpreter at the
|
|
206
|
-
// end of the token.
|
|
207
|
-
if (t != IntStream.EOF) {
|
|
208
|
-
consume(input);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (target.isAcceptState) {
|
|
212
|
-
captureSimState(prevAccept, input, target);
|
|
213
|
-
if (t == IntStream.EOF) {
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
t = input.LA(1);
|
|
219
|
-
s = target; // flip; current DFA target becomes new src/from state
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return failOrAccept(prevAccept, input, s.configs, t);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/// Get an existing target state for an edge in the DFA. If the target state
|
|
226
|
-
/// for the edge has not yet been computed or is otherwise not available,
|
|
227
|
-
/// this method returns null.
|
|
228
|
-
///
|
|
229
|
-
/// @param s The current DFA state
|
|
230
|
-
/// @param t The next input symbol
|
|
231
|
-
/// @return The existing target DFA state for the given input symbol
|
|
232
|
-
/// [t], or null if the target state for this edge is not
|
|
233
|
-
/// already cached
|
|
234
|
-
|
|
235
|
-
DFAState getExistingTargetState(DFAState s, int t) {
|
|
236
|
-
if (s.edges == null || t < MIN_DFA_EDGE || t > MAX_DFA_EDGE) {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
final target = s.edges[t - MIN_DFA_EDGE];
|
|
241
|
-
if (debug && target != null) {
|
|
242
|
-
log('reuse state ${s.stateNumber} edge to ${target.stateNumber}',
|
|
243
|
-
level: Level.FINE.value);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return target;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/// Compute a target state for an edge in the DFA, and attempt to add the
|
|
250
|
-
/// computed state and corresponding edge to the DFA.
|
|
251
|
-
///
|
|
252
|
-
/// @param input The input stream
|
|
253
|
-
/// @param s The current DFA state
|
|
254
|
-
/// @param t The next input symbol
|
|
255
|
-
///
|
|
256
|
-
/// @return The computed target DFA state for the given input symbol
|
|
257
|
-
/// [t]. If [t] does not lead to a valid DFA state, this method
|
|
258
|
-
/// returns {@link #ERROR}.
|
|
259
|
-
|
|
260
|
-
DFAState computeTargetState(CharStream input, DFAState s, int t) {
|
|
261
|
-
ATNConfigSet reach = OrderedATNConfigSet();
|
|
262
|
-
|
|
263
|
-
// if we don't find an existing DFA state
|
|
264
|
-
// Fill reach starting from closure, following t transitions
|
|
265
|
-
getReachableConfigSet(input, s.configs, reach, t);
|
|
266
|
-
|
|
267
|
-
if (reach.isEmpty) {
|
|
268
|
-
// we got nowhere on t from s
|
|
269
|
-
if (!reach.hasSemanticContext) {
|
|
270
|
-
// we got nowhere on t, don't throw out this knowledge; it'd
|
|
271
|
-
// cause a failover from DFA later.
|
|
272
|
-
addDFAEdge(s, t, ATNSimulator.ERROR);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// stop when we can't match any more char
|
|
276
|
-
return ATNSimulator.ERROR;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Add an edge from s to target DFA found/created for reach
|
|
280
|
-
return addDFAEdgeByConfig(s, t, reach);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
int failOrAccept(
|
|
284
|
-
SimState prevAccept, CharStream input, ATNConfigSet reach, int t) {
|
|
285
|
-
if (prevAccept.dfaState != null) {
|
|
286
|
-
final lexerActionExecutor =
|
|
287
|
-
prevAccept.dfaState.lexerActionExecutor;
|
|
288
|
-
accept(input, lexerActionExecutor, startIndex, prevAccept.index,
|
|
289
|
-
prevAccept.line, prevAccept.charPos);
|
|
290
|
-
return prevAccept.dfaState.prediction;
|
|
291
|
-
} else {
|
|
292
|
-
// if no accept and EOF is first char, return EOF
|
|
293
|
-
if (t == IntStream.EOF && input.index == startIndex) {
|
|
294
|
-
return Token.EOF;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
throw LexerNoViableAltException(recog, input, startIndex, reach);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/// Given a starting configuration set, figure out all ATN configurations
|
|
302
|
-
/// we can reach upon input [t]. Parameter [reach] is a return
|
|
303
|
-
/// parameter.
|
|
304
|
-
void getReachableConfigSet(
|
|
305
|
-
CharStream input, ATNConfigSet configs, ATNConfigSet reach, int t) {
|
|
306
|
-
// this is used to skip processing for configs which have a lower priority
|
|
307
|
-
// than a config that already reached an accept state for the same rule
|
|
308
|
-
var skipAlt = ATN.INVALID_ALT_NUMBER;
|
|
309
|
-
for (var c in configs) {
|
|
310
|
-
final currentAltReachedAcceptState = c.alt == skipAlt;
|
|
311
|
-
if (currentAltReachedAcceptState &&
|
|
312
|
-
(c as LexerATNConfig).hasPassedThroughNonGreedyDecision()) {
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (debug) {
|
|
317
|
-
log('testing ${getTokenName(t)} at ${c.toString(recog, true)}\n',
|
|
318
|
-
level: Level.FINE.value);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
final n = c.state.numberOfTransitions;
|
|
322
|
-
for (var ti = 0; ti < n; ti++) {
|
|
323
|
-
// for each transition
|
|
324
|
-
final trans = c.state.transition(ti);
|
|
325
|
-
final target = getReachableTarget(trans, t);
|
|
326
|
-
if (target != null) {
|
|
327
|
-
var lexerActionExecutor =
|
|
328
|
-
(c as LexerATNConfig).lexerActionExecutor;
|
|
329
|
-
if (lexerActionExecutor != null) {
|
|
330
|
-
lexerActionExecutor = lexerActionExecutor
|
|
331
|
-
.fixOffsetBeforeMatch(input.index - startIndex);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
final treatEofAsEpsilon = t == IntStream.EOF;
|
|
335
|
-
if (closure(
|
|
336
|
-
input,
|
|
337
|
-
LexerATNConfig.dup(c, target,
|
|
338
|
-
lexerActionExecutor: lexerActionExecutor),
|
|
339
|
-
reach,
|
|
340
|
-
currentAltReachedAcceptState,
|
|
341
|
-
true,
|
|
342
|
-
treatEofAsEpsilon)) {
|
|
343
|
-
// any remaining configs for this alt have a lower priority than
|
|
344
|
-
// the one that just reached an accept state.
|
|
345
|
-
skipAlt = c.alt;
|
|
346
|
-
break;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
void accept(CharStream input, LexerActionExecutor lexerActionExecutor,
|
|
354
|
-
int startIndex, int index, int line, int charPos) {
|
|
355
|
-
if (debug) {
|
|
356
|
-
log('ACTION $lexerActionExecutor\n', level: Level.FINE.value);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// seek to after last char in token
|
|
360
|
-
input.seek(index);
|
|
361
|
-
this.line = line;
|
|
362
|
-
charPositionInLine = charPos;
|
|
363
|
-
|
|
364
|
-
if (lexerActionExecutor != null && recog != null) {
|
|
365
|
-
lexerActionExecutor.execute(recog, input, startIndex);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
ATNState getReachableTarget(Transition trans, int t) {
|
|
370
|
-
if (trans.matches(t, Lexer.MIN_CHAR_VALUE, Lexer.MAX_CHAR_VALUE)) {
|
|
371
|
-
return trans.target;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
ATNConfigSet computeStartState(CharStream input, ATNState p) {
|
|
378
|
-
PredictionContext initialContext = PredictionContext.EMPTY;
|
|
379
|
-
ATNConfigSet configs = OrderedATNConfigSet();
|
|
380
|
-
for (var i = 0; i < p.numberOfTransitions; i++) {
|
|
381
|
-
final target = p.transition(i).target;
|
|
382
|
-
final c = LexerATNConfig(target, i + 1, initialContext);
|
|
383
|
-
closure(input, c, configs, false, false, false);
|
|
384
|
-
}
|
|
385
|
-
return configs;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/// Since the alternatives within any lexer decision are ordered by
|
|
389
|
-
/// preference, this method stops pursuing the closure as soon as an accept
|
|
390
|
-
/// state is reached. After the first accept state is reached by depth-first
|
|
391
|
-
/// search from [config], all other (potentially reachable) states for
|
|
392
|
-
/// this rule would have a lower priority.
|
|
393
|
-
///
|
|
394
|
-
/// @return [true] if an accept state is reached, otherwise
|
|
395
|
-
/// [false].
|
|
396
|
-
bool closure(
|
|
397
|
-
CharStream input,
|
|
398
|
-
LexerATNConfig config,
|
|
399
|
-
ATNConfigSet configs,
|
|
400
|
-
bool currentAltReachedAcceptState,
|
|
401
|
-
bool speculative,
|
|
402
|
-
bool treatEofAsEpsilon) {
|
|
403
|
-
if (debug) {
|
|
404
|
-
log('closure(' + config.toString(recog, true) + ')',
|
|
405
|
-
level: Level.FINE.value);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (config.state is RuleStopState) {
|
|
409
|
-
if (debug) {
|
|
410
|
-
if (recog != null) {
|
|
411
|
-
log('closure at ${recog.ruleNames[config.state.ruleIndex]} rule stop $config\n',
|
|
412
|
-
level: Level.FINE.value);
|
|
413
|
-
} else {
|
|
414
|
-
log('closure at rule stop $config\n', level: Level.FINE.value);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (config.context == null || config.context.hasEmptyPath()) {
|
|
419
|
-
if (config.context == null || config.context.isEmpty) {
|
|
420
|
-
configs.add(config);
|
|
421
|
-
return true;
|
|
422
|
-
} else {
|
|
423
|
-
configs.add(LexerATNConfig.dup(config, config.state,
|
|
424
|
-
context: PredictionContext.EMPTY));
|
|
425
|
-
currentAltReachedAcceptState = true;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (config.context != null && !config.context.isEmpty) {
|
|
430
|
-
for (var i = 0; i < config.context.length; i++) {
|
|
431
|
-
if (config.context.getReturnState(i) !=
|
|
432
|
-
PredictionContext.EMPTY_RETURN_STATE) {
|
|
433
|
-
final newContext =
|
|
434
|
-
config.context.getParent(i); // "pop" return state
|
|
435
|
-
final returnState = atn.states[config.context.getReturnState(i)];
|
|
436
|
-
final c = LexerATNConfig.dup(config, returnState,
|
|
437
|
-
context: newContext);
|
|
438
|
-
currentAltReachedAcceptState = closure(input, c, configs,
|
|
439
|
-
currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return currentAltReachedAcceptState;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// optimization
|
|
448
|
-
if (!config.state.onlyHasEpsilonTransitions()) {
|
|
449
|
-
if (!currentAltReachedAcceptState ||
|
|
450
|
-
!config.hasPassedThroughNonGreedyDecision()) {
|
|
451
|
-
configs.add(config);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
final p = config.state;
|
|
456
|
-
for (var i = 0; i < p.numberOfTransitions; i++) {
|
|
457
|
-
final t = p.transition(i);
|
|
458
|
-
final c = getEpsilonTarget(
|
|
459
|
-
input, config, t, configs, speculative, treatEofAsEpsilon);
|
|
460
|
-
if (c != null) {
|
|
461
|
-
currentAltReachedAcceptState = closure(input, c, configs,
|
|
462
|
-
currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
return currentAltReachedAcceptState;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// side-effect: can alter configs.hasSemanticContext
|
|
470
|
-
|
|
471
|
-
LexerATNConfig getEpsilonTarget(
|
|
472
|
-
CharStream input,
|
|
473
|
-
LexerATNConfig config,
|
|
474
|
-
Transition t,
|
|
475
|
-
ATNConfigSet configs,
|
|
476
|
-
bool speculative,
|
|
477
|
-
bool treatEofAsEpsilon) {
|
|
478
|
-
LexerATNConfig c;
|
|
479
|
-
switch (t.type) {
|
|
480
|
-
case TransitionType.RULE:
|
|
481
|
-
RuleTransition ruleTransition = t;
|
|
482
|
-
PredictionContext newContext = SingletonPredictionContext.create(
|
|
483
|
-
config.context, ruleTransition.followState.stateNumber);
|
|
484
|
-
c = LexerATNConfig.dup(config, t.target, context: newContext);
|
|
485
|
-
break;
|
|
486
|
-
|
|
487
|
-
case TransitionType.PRECEDENCE:
|
|
488
|
-
throw UnsupportedError(
|
|
489
|
-
'Precedence predicates are not supported in lexers.');
|
|
490
|
-
case TransitionType.PREDICATE:
|
|
491
|
-
/* Track traversing semantic predicates. If we traverse,
|
|
492
|
-
we cannot add a DFA state for this "reach" computation
|
|
493
|
-
because the DFA would not test the predicate again in the
|
|
494
|
-
future. Rather than creating collections of semantic predicates
|
|
495
|
-
like v3 and testing them on prediction, v4 will test them on the
|
|
496
|
-
fly all the time using the ATN not the DFA. This is slower but
|
|
497
|
-
semantically it's not used that often. One of the key elements to
|
|
498
|
-
this predicate mechanism is not adding DFA states that see
|
|
499
|
-
predicates immediately afterwards in the ATN. For example,
|
|
500
|
-
|
|
501
|
-
a : ID {p1}? | ID {p2}? ;
|
|
502
|
-
|
|
503
|
-
should create the start state for rule 'a' (to save start state
|
|
504
|
-
competition), but should not create target of ID state. The
|
|
505
|
-
collection of ATN states the following ID references includes
|
|
506
|
-
states reached by traversing predicates. Since this is when we
|
|
507
|
-
test them, we cannot cash the DFA state target of ID.
|
|
508
|
-
*/
|
|
509
|
-
PredicateTransition pt = t;
|
|
510
|
-
if (debug) {
|
|
511
|
-
log('EVAL rule ${pt.ruleIndex}:${pt.predIndex}',
|
|
512
|
-
level: Level.FINE.value);
|
|
513
|
-
}
|
|
514
|
-
configs.hasSemanticContext = true;
|
|
515
|
-
if (evaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative)) {
|
|
516
|
-
c = LexerATNConfig.dup(config, t.target);
|
|
517
|
-
}
|
|
518
|
-
break;
|
|
519
|
-
case TransitionType.ACTION:
|
|
520
|
-
if (config.context == null || config.context.hasEmptyPath()) {
|
|
521
|
-
// execute actions anywhere in the start rule for a token.
|
|
522
|
-
//
|
|
523
|
-
// TODO: if the entry rule is invoked recursively, some
|
|
524
|
-
// actions may be executed during the recursive call. The
|
|
525
|
-
// problem can appear when hasEmptyPath() is true but
|
|
526
|
-
// isEmpty is false. In this case, the config needs to be
|
|
527
|
-
// split into two contexts - one with just the empty path
|
|
528
|
-
// and another with everything but the empty path.
|
|
529
|
-
// Unfortunately, the current algorithm does not allow
|
|
530
|
-
// getEpsilonTarget to return two configurations, so
|
|
531
|
-
// additional modifications are needed before we can support
|
|
532
|
-
// the split operation.
|
|
533
|
-
final lexerActionExecutor = LexerActionExecutor.append(
|
|
534
|
-
config.lexerActionExecutor,
|
|
535
|
-
atn.lexerActions[(t as ActionTransition).actionIndex]);
|
|
536
|
-
c = LexerATNConfig.dup(config, t.target,
|
|
537
|
-
lexerActionExecutor: lexerActionExecutor);
|
|
538
|
-
} else {
|
|
539
|
-
// ignore actions in referenced rules
|
|
540
|
-
c = LexerATNConfig.dup(config, t.target);
|
|
541
|
-
}
|
|
542
|
-
break;
|
|
543
|
-
|
|
544
|
-
case TransitionType.EPSILON:
|
|
545
|
-
c = LexerATNConfig.dup(config, t.target);
|
|
546
|
-
break;
|
|
547
|
-
|
|
548
|
-
case TransitionType.ATOM:
|
|
549
|
-
case TransitionType.RANGE:
|
|
550
|
-
case TransitionType.SET:
|
|
551
|
-
if (treatEofAsEpsilon) {
|
|
552
|
-
if (t.matches(
|
|
553
|
-
IntStream.EOF, Lexer.MIN_CHAR_VALUE, Lexer.MAX_CHAR_VALUE)) {
|
|
554
|
-
c = LexerATNConfig.dup(config, t.target);
|
|
555
|
-
break;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
break;
|
|
559
|
-
case TransitionType.NOT_SET:
|
|
560
|
-
break;
|
|
561
|
-
case TransitionType.WILDCARD:
|
|
562
|
-
break;
|
|
563
|
-
case TransitionType.INVALID:
|
|
564
|
-
throw ArgumentError.value(t.type, 'TransitionType');
|
|
565
|
-
break;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
return c;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/// Evaluate a predicate specified in the lexer.
|
|
572
|
-
///
|
|
573
|
-
/// <p>If [speculative] is [true], this method was called before
|
|
574
|
-
/// {@link #consume} for the matched character. This method should call
|
|
575
|
-
/// {@link #consume} before evaluating the predicate to ensure position
|
|
576
|
-
/// sensitive values, including {@link Lexer#getText}, {@link Lexer#getLine},
|
|
577
|
-
/// and {@link Lexer#getCharPositionInLine}, properly reflect the current
|
|
578
|
-
/// lexer state. This method should restore [input] and the simulator
|
|
579
|
-
/// to the original state before returning (i.e. undo the actions made by the
|
|
580
|
-
/// call to {@link #consume}.</p>
|
|
581
|
-
///
|
|
582
|
-
/// @param input The input stream.
|
|
583
|
-
/// @param ruleIndex The rule containing the predicate.
|
|
584
|
-
/// @param predIndex The index of the predicate within the rule.
|
|
585
|
-
/// @param speculative [true] if the current index in [input] is
|
|
586
|
-
/// one character before the predicate's location.
|
|
587
|
-
///
|
|
588
|
-
/// @return [true] if the specified predicate evaluates to
|
|
589
|
-
/// [true].
|
|
590
|
-
bool evaluatePredicate(
|
|
591
|
-
CharStream input, int ruleIndex, int predIndex, bool speculative) {
|
|
592
|
-
// assume true if no recognizer was provided
|
|
593
|
-
if (recog == null) {
|
|
594
|
-
return true;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
if (!speculative) {
|
|
598
|
-
return recog.sempred(null, ruleIndex, predIndex);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
final savedCharPositionInLine = charPositionInLine;
|
|
602
|
-
final savedLine = line;
|
|
603
|
-
final index = input.index;
|
|
604
|
-
final marker = input.mark();
|
|
605
|
-
try {
|
|
606
|
-
consume(input);
|
|
607
|
-
return recog.sempred(null, ruleIndex, predIndex);
|
|
608
|
-
} finally {
|
|
609
|
-
charPositionInLine = savedCharPositionInLine;
|
|
610
|
-
line = savedLine;
|
|
611
|
-
input.seek(index);
|
|
612
|
-
input.release(marker);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
void captureSimState(SimState settings, CharStream input, DFAState dfaState) {
|
|
617
|
-
settings.index = input.index;
|
|
618
|
-
settings.line = line;
|
|
619
|
-
settings.charPos = charPositionInLine;
|
|
620
|
-
settings.dfaState = dfaState;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
DFAState addDFAEdgeByConfig(DFAState from, int t, ATNConfigSet q) {
|
|
624
|
-
/* leading to this call, ATNConfigSet.hasSemanticContext is used as a
|
|
625
|
-
* marker indicating dynamic predicate evaluation makes this edge
|
|
626
|
-
* dependent on the specific input sequence, so the static edge in the
|
|
627
|
-
* DFA should be omitted. The target DFAState is still created since
|
|
628
|
-
* execATN has the ability to resynchronize with the DFA state cache
|
|
629
|
-
* following the predicate evaluation step.
|
|
630
|
-
*
|
|
631
|
-
* TJP notes: next time through the DFA, we see a pred again and eval.
|
|
632
|
-
* If that gets us to a previously created (but dangling) DFA
|
|
633
|
-
* state, we can continue in pure DFA mode from there.
|
|
634
|
-
*/
|
|
635
|
-
final suppressEdge = q.hasSemanticContext;
|
|
636
|
-
q.hasSemanticContext = false;
|
|
637
|
-
|
|
638
|
-
final to = addDFAState(q);
|
|
639
|
-
|
|
640
|
-
if (suppressEdge) {
|
|
641
|
-
return to;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
addDFAEdge(from, t, to);
|
|
645
|
-
return to;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
void addDFAEdge(DFAState p, int t, DFAState q) {
|
|
649
|
-
if (t < MIN_DFA_EDGE || t > MAX_DFA_EDGE) {
|
|
650
|
-
// Only track edges within the DFA bounds
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
if (debug) {
|
|
655
|
-
log('EDGE $p -> $q upon ${String.fromCharCode(t)}',
|
|
656
|
-
level: Level.FINE.value);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
p.edges ??= List<DFAState>(MAX_DFA_EDGE - MIN_DFA_EDGE + 1);
|
|
660
|
-
p.edges[t - MIN_DFA_EDGE] = q; // connect
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/// Add a new DFA state if there isn't one with this set of
|
|
664
|
-
/// configurations already. This method also detects the first
|
|
665
|
-
/// configuration containing an ATN rule stop state. Later, when
|
|
666
|
-
/// traversing the DFA, we will know which rule to accept.
|
|
667
|
-
DFAState addDFAState(ATNConfigSet configs) {
|
|
668
|
-
/* the lexer evaluates predicates on-the-fly; by this point configs
|
|
669
|
-
* should not contain any configurations with unevaluated predicates.
|
|
670
|
-
*/
|
|
671
|
-
assert(!configs.hasSemanticContext);
|
|
672
|
-
|
|
673
|
-
final proposed = DFAState(configs: configs);
|
|
674
|
-
ATNConfig firstConfigWithRuleStopState;
|
|
675
|
-
for (var c in configs) {
|
|
676
|
-
if (c.state is RuleStopState) {
|
|
677
|
-
firstConfigWithRuleStopState = c;
|
|
678
|
-
break;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
if (firstConfigWithRuleStopState != null) {
|
|
683
|
-
proposed.isAcceptState = true;
|
|
684
|
-
proposed.lexerActionExecutor =
|
|
685
|
-
(firstConfigWithRuleStopState as LexerATNConfig)
|
|
686
|
-
.lexerActionExecutor;
|
|
687
|
-
proposed.prediction =
|
|
688
|
-
atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex];
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
final dfa = decisionToDFA[mode];
|
|
692
|
-
final existing = dfa.states[proposed];
|
|
693
|
-
if (existing != null) return existing;
|
|
694
|
-
|
|
695
|
-
final newState = proposed;
|
|
696
|
-
|
|
697
|
-
newState.stateNumber = dfa.states.length;
|
|
698
|
-
configs.readOnly = true;
|
|
699
|
-
newState.configs = configs;
|
|
700
|
-
dfa.states[newState] = newState;
|
|
701
|
-
return newState;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
DFA getDFA(int mode) {
|
|
705
|
-
return decisionToDFA[mode];
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
/// Get the text matched so far for the current token.
|
|
709
|
-
|
|
710
|
-
String getText(CharStream input) {
|
|
711
|
-
// index is first lookahead char, don't include.
|
|
712
|
-
return input.getText(Interval.of(startIndex, input.index - 1));
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
void consume(CharStream input) {
|
|
716
|
-
final curChar = input.LA(1);
|
|
717
|
-
if (curChar == 10) { // Is new line
|
|
718
|
-
line++;
|
|
719
|
-
charPositionInLine = 0;
|
|
720
|
-
} else {
|
|
721
|
-
charPositionInLine++;
|
|
722
|
-
}
|
|
723
|
-
input.consume();
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
String getTokenName(int t) {
|
|
727
|
-
if (t == -1) return 'EOF';
|
|
728
|
-
//if ( atn.g!=null ) return atn.g.getTokenDisplayName(t);
|
|
729
|
-
return "'${String.fromCharCode(t)}'";
|
|
730
|
-
}
|
|
731
|
-
}
|