-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleJavaParserTokenManager.java
More file actions
586 lines (569 loc) · 15.4 KB
/
SimpleJavaParserTokenManager.java
File metadata and controls
586 lines (569 loc) · 15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
/* Generated By:JavaCC: Do not edit this line. SimpleJavaParserTokenManager.java */
/** Token Manager. */
public class SimpleJavaParserTokenManager implements SimpleJavaParserConstants
{
/** Debug output. */
public static java.io.PrintStream debugStream = System.out;
/** Set debug output. */
public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
private static final int jjStopStringLiteralDfa_0(int pos, long active0)
{
switch (pos)
{
case 0:
if ((active0 & 0xe0L) != 0L)
{
jjmatchedKind = 14;
return 14;
}
return -1;
case 1:
if ((active0 & 0xe0L) != 0L)
{
jjmatchedKind = 14;
jjmatchedPos = 1;
return 14;
}
return -1;
case 2:
if ((active0 & 0xe0L) != 0L)
{
jjmatchedKind = 14;
jjmatchedPos = 2;
return 14;
}
return -1;
case 3:
if ((active0 & 0xe0L) != 0L)
{
jjmatchedKind = 14;
jjmatchedPos = 3;
return 14;
}
return -1;
case 4:
if ((active0 & 0x40L) != 0L)
return 14;
if ((active0 & 0xa0L) != 0L)
{
jjmatchedKind = 14;
jjmatchedPos = 4;
return 14;
}
return -1;
case 5:
if ((active0 & 0x20L) != 0L)
return 14;
if ((active0 & 0x80L) != 0L)
{
jjmatchedKind = 14;
jjmatchedPos = 5;
return 14;
}
return -1;
case 6:
if ((active0 & 0x80L) != 0L)
{
jjmatchedKind = 14;
jjmatchedPos = 6;
return 14;
}
return -1;
default :
return -1;
}
}
private static final int jjStartNfa_0(int pos, long active0)
{
return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
}
static private int jjStopAtPos(int pos, int kind)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
return pos + 1;
}
static private int jjMoveStringLiteralDfa0_0()
{
switch(curChar)
{
case 40:
return jjStopAtPos(0, 11);
case 41:
return jjStopAtPos(0, 12);
case 44:
return jjStopAtPos(0, 13);
case 97:
return jjMoveStringLiteralDfa1_0(0x80L);
case 99:
return jjMoveStringLiteralDfa1_0(0x40L);
case 112:
return jjMoveStringLiteralDfa1_0(0x20L);
case 123:
return jjStopAtPos(0, 9);
case 125:
return jjStopAtPos(0, 10);
default :
return jjMoveNfa_0(3, 0);
}
}
static private int jjMoveStringLiteralDfa1_0(long active0)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(0, active0);
return 1;
}
switch(curChar)
{
case 98:
return jjMoveStringLiteralDfa2_0(active0, 0x80L);
case 108:
return jjMoveStringLiteralDfa2_0(active0, 0x40L);
case 117:
return jjMoveStringLiteralDfa2_0(active0, 0x20L);
default :
break;
}
return jjStartNfa_0(0, active0);
}
static private int jjMoveStringLiteralDfa2_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(0, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(1, active0);
return 2;
}
switch(curChar)
{
case 97:
return jjMoveStringLiteralDfa3_0(active0, 0x40L);
case 98:
return jjMoveStringLiteralDfa3_0(active0, 0x20L);
case 115:
return jjMoveStringLiteralDfa3_0(active0, 0x80L);
default :
break;
}
return jjStartNfa_0(1, active0);
}
static private int jjMoveStringLiteralDfa3_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(1, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(2, active0);
return 3;
}
switch(curChar)
{
case 108:
return jjMoveStringLiteralDfa4_0(active0, 0x20L);
case 115:
return jjMoveStringLiteralDfa4_0(active0, 0x40L);
case 116:
return jjMoveStringLiteralDfa4_0(active0, 0x80L);
default :
break;
}
return jjStartNfa_0(2, active0);
}
static private int jjMoveStringLiteralDfa4_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(2, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(3, active0);
return 4;
}
switch(curChar)
{
case 105:
return jjMoveStringLiteralDfa5_0(active0, 0x20L);
case 114:
return jjMoveStringLiteralDfa5_0(active0, 0x80L);
case 115:
if ((active0 & 0x40L) != 0L)
return jjStartNfaWithStates_0(4, 6, 14);
break;
default :
break;
}
return jjStartNfa_0(3, active0);
}
static private int jjMoveStringLiteralDfa5_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(3, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(4, active0);
return 5;
}
switch(curChar)
{
case 97:
return jjMoveStringLiteralDfa6_0(active0, 0x80L);
case 99:
if ((active0 & 0x20L) != 0L)
return jjStartNfaWithStates_0(5, 5, 14);
break;
default :
break;
}
return jjStartNfa_0(4, active0);
}
static private int jjMoveStringLiteralDfa6_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(4, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(5, active0);
return 6;
}
switch(curChar)
{
case 99:
return jjMoveStringLiteralDfa7_0(active0, 0x80L);
default :
break;
}
return jjStartNfa_0(5, active0);
}
static private int jjMoveStringLiteralDfa7_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(5, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(6, active0);
return 7;
}
switch(curChar)
{
case 116:
if ((active0 & 0x80L) != 0L)
return jjStartNfaWithStates_0(7, 7, 14);
break;
default :
break;
}
return jjStartNfa_0(6, active0);
}
static private int jjStartNfaWithStates_0(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_0(state, pos + 1);
}
static private int jjMoveNfa_0(int startState, int curPos)
{
int startsAt = 0;
jjnewStateCnt = 15;
int i = 1;
jjstateSet[0] = startState;
int kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
do
{
switch(jjstateSet[--i])
{
case 14:
if ((0x3ff000000000000L & l) == 0L)
break;
kind = 14;
jjstateSet[jjnewStateCnt++] = 14;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
do
{
switch(jjstateSet[--i])
{
case 3:
if ((0x7fffffe07fffffeL & l) != 0L)
{
if (kind > 14)
kind = 14;
jjCheckNAdd(14);
}
if (curChar == 100)
jjstateSet[jjnewStateCnt++] = 11;
else if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 5;
else if (curChar == 118)
jjstateSet[jjnewStateCnt++] = 2;
break;
case 0:
if (curChar == 100 && kind > 8)
kind = 8;
break;
case 1:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 0;
break;
case 2:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 1;
break;
case 4:
if (curChar == 116 && kind > 8)
kind = 8;
break;
case 5:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 4;
break;
case 6:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 5;
break;
case 7:
if (curChar == 101 && kind > 8)
kind = 8;
break;
case 8:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 7;
break;
case 9:
if (curChar == 98)
jjstateSet[jjnewStateCnt++] = 8;
break;
case 10:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 9;
break;
case 11:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 10;
break;
case 12:
if (curChar == 100)
jjstateSet[jjnewStateCnt++] = 11;
break;
case 13:
case 14:
if ((0x7fffffe07fffffeL & l) == 0L)
break;
if (kind > 14)
kind = 14;
jjCheckNAdd(14);
break;
default : break;
}
} while(i != startsAt);
}
else
{
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
do
{
switch(jjstateSet[--i])
{
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 15 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
static final int[] jjnextStates = {
};
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, "\160\165\142\154\151\143",
"\143\154\141\163\163", "\141\142\163\164\162\141\143\164", null, "\173", "\175", "\50", "\51", "\54",
null, };
/** Lexer state names. */
public static final String[] lexStateNames = {
"DEFAULT",
};
static final long[] jjtoToken = {
0x7fe1L,
};
static final long[] jjtoSkip = {
0x1eL,
};
static protected SimpleCharStream input_stream;
static private final int[] jjrounds = new int[15];
static private final int[] jjstateSet = new int[30];
static protected char curChar;
/** Constructor. */
public SimpleJavaParserTokenManager(SimpleCharStream stream){
if (input_stream != null)
throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
input_stream = stream;
}
/** Constructor. */
public SimpleJavaParserTokenManager(SimpleCharStream stream, int lexState){
this(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
static public void ReInit(SimpleCharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
static private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 15; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
static public void ReInit(SimpleCharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
/** Switch to specified lex state. */
static public void SwitchTo(int lexState)
{
if (lexState >= 1 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
static protected Token jjFillToken()
{
final Token t;
final String curTokenImage;
final int beginLine;
final int endLine;
final int beginColumn;
final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
curTokenImage = (im == null) ? input_stream.GetImage() : im;
beginLine = input_stream.getBeginLine();
beginColumn = input_stream.getBeginColumn();
endLine = input_stream.getEndLine();
endColumn = input_stream.getEndColumn();
t = Token.newToken(jjmatchedKind, curTokenImage);
t.beginLine = beginLine;
t.endLine = endLine;
t.beginColumn = beginColumn;
t.endColumn = endColumn;
return t;
}
static int curLexState = 0;
static int defaultLexState = 0;
static int jjnewStateCnt;
static int jjround;
static int jjmatchedPos;
static int jjmatchedKind;
/** Get the next Token. */
public static Token getNextToken()
{
Token matchedToken;
int curPos = 0;
EOFLoop :
for (;;)
{
try
{
curChar = input_stream.BeginToken();
}
catch(java.io.IOException e)
{
jjmatchedKind = 0;
matchedToken = jjFillToken();
return matchedToken;
}
try { input_stream.backup(0);
while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
curChar = input_stream.BeginToken();
}
catch (java.io.IOException e1) { continue EOFLoop; }
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_0();
if (jjmatchedKind != 0x7fffffff)
{
if (jjmatchedPos + 1 < curPos)
input_stream.backup(curPos - jjmatchedPos - 1);
if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
{
matchedToken = jjFillToken();
return matchedToken;
}
else
{
continue EOFLoop;
}
}
int error_line = input_stream.getEndLine();
int error_column = input_stream.getEndColumn();
String error_after = null;
boolean EOFSeen = false;
try { input_stream.readChar(); input_stream.backup(1); }
catch (java.io.IOException e1) {
EOFSeen = true;
error_after = curPos <= 1 ? "" : input_stream.GetImage();
if (curChar == '\n' || curChar == '\r') {
error_line++;
error_column = 0;
}
else
error_column++;
}
if (!EOFSeen) {
input_stream.backup(1);
error_after = curPos <= 1 ? "" : input_stream.GetImage();
}
throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
}
}
static private void jjCheckNAdd(int state)
{
if (jjrounds[state] != jjround)
{
jjstateSet[jjnewStateCnt++] = state;
jjrounds[state] = jjround;
}
}
static private void jjAddStates(int start, int end)
{
do {
jjstateSet[jjnewStateCnt++] = jjnextStates[start];
} while (start++ != end);
}
static private void jjCheckNAddTwoStates(int state1, int state2)
{
jjCheckNAdd(state1);
jjCheckNAdd(state2);
}
}