1
2 package sl;
3 import java.io.BufferedReader;
4 import java.io.BufferedWriter;
5 import java.io.StringReader;
6 import java.io.InputStreamReader;
7 import java.io.OutputStreamWriter;
8 import java.util.List;
9 import java.util.ArrayList;
10
11 public class SL0ParserTokenManager implements SL0ParserConstants
12 {
13 private final int jjStopStringLiteralDfa_0(int pos, long active0)
14 {
15 switch (pos)
16 {
17 case 0:
18 if ((active0 & 0x80L) != 0L)
19 {
20 jjmatchedKind = 12;
21 return 9;
22 }
23 return -1;
24 case 1:
25 if ((active0 & 0x80L) != 0L)
26 {
27 jjmatchedKind = 12;
28 jjmatchedPos = 1;
29 return 9;
30 }
31 return -1;
32 case 2:
33 if ((active0 & 0x80L) != 0L)
34 {
35 jjmatchedKind = 12;
36 jjmatchedPos = 2;
37 return 9;
38 }
39 return -1;
40 case 3:
41 if ((active0 & 0x80L) != 0L)
42 {
43 jjmatchedKind = 12;
44 jjmatchedPos = 3;
45 return 9;
46 }
47 return -1;
48 case 4:
49 if ((active0 & 0x80L) != 0L)
50 {
51 jjmatchedKind = 12;
52 jjmatchedPos = 4;
53 return 9;
54 }
55 return -1;
56 default :
57 return -1;
58 }
59 }
60 private final int jjStartNfa_0(int pos, long active0)
61 {
62 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
63 }
64 private final int jjStopAtPos(int pos, int kind)
65 {
66 jjmatchedKind = kind;
67 jjmatchedPos = pos;
68 return pos + 1;
69 }
70 private final int jjStartNfaWithStates_0(int pos, int kind, int state)
71 {
72 jjmatchedKind = kind;
73 jjmatchedPos = pos;
74 try { curChar = input_stream.readChar(); }
75 catch(java.io.IOException e) { return pos + 1; }
76 return jjMoveNfa_0(state, pos + 1);
77 }
78 private final int jjMoveStringLiteralDfa0_0()
79 {
80 switch(curChar)
81 {
82 case 40:
83 return jjStopAtPos(0, 5);
84 case 41:
85 return jjStopAtPos(0, 6);
86 case 97:
87 return jjMoveStringLiteralDfa1_0(0x80L);
88 default :
89 return jjMoveNfa_0(8, 0);
90 }
91 }
92 private final int jjMoveStringLiteralDfa1_0(long active0)
93 {
94 try { curChar = input_stream.readChar(); }
95 catch(java.io.IOException e) {
96 jjStopStringLiteralDfa_0(0, active0);
97 return 1;
98 }
99 switch(curChar)
100 {
101 case 99:
102 return jjMoveStringLiteralDfa2_0(active0, 0x80L);
103 default :
104 break;
105 }
106 return jjStartNfa_0(0, active0);
107 }
108 private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
109 {
110 if (((active0 &= old0)) == 0L)
111 return jjStartNfa_0(0, old0);
112 try { curChar = input_stream.readChar(); }
113 catch(java.io.IOException e) {
114 jjStopStringLiteralDfa_0(1, active0);
115 return 2;
116 }
117 switch(curChar)
118 {
119 case 116:
120 return jjMoveStringLiteralDfa3_0(active0, 0x80L);
121 default :
122 break;
123 }
124 return jjStartNfa_0(1, active0);
125 }
126 private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
127 {
128 if (((active0 &= old0)) == 0L)
129 return jjStartNfa_0(1, old0);
130 try { curChar = input_stream.readChar(); }
131 catch(java.io.IOException e) {
132 jjStopStringLiteralDfa_0(2, active0);
133 return 3;
134 }
135 switch(curChar)
136 {
137 case 105:
138 return jjMoveStringLiteralDfa4_0(active0, 0x80L);
139 default :
140 break;
141 }
142 return jjStartNfa_0(2, active0);
143 }
144 private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
145 {
146 if (((active0 &= old0)) == 0L)
147 return jjStartNfa_0(2, old0);
148 try { curChar = input_stream.readChar(); }
149 catch(java.io.IOException e) {
150 jjStopStringLiteralDfa_0(3, active0);
151 return 4;
152 }
153 switch(curChar)
154 {
155 case 111:
156 return jjMoveStringLiteralDfa5_0(active0, 0x80L);
157 default :
158 break;
159 }
160 return jjStartNfa_0(3, active0);
161 }
162 private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
163 {
164 if (((active0 &= old0)) == 0L)
165 return jjStartNfa_0(3, old0);
166 try { curChar = input_stream.readChar(); }
167 catch(java.io.IOException e) {
168 jjStopStringLiteralDfa_0(4, active0);
169 return 5;
170 }
171 switch(curChar)
172 {
173 case 110:
174 if ((active0 & 0x80L) != 0L)
175 return jjStartNfaWithStates_0(5, 7, 9);
176 break;
177 default :
178 break;
179 }
180 return jjStartNfa_0(4, active0);
181 }
182 private final void jjCheckNAdd(int state)
183 {
184 if (jjrounds[state] != jjround)
185 {
186 jjstateSet[jjnewStateCnt++] = state;
187 jjrounds[state] = jjround;
188 }
189 }
190 private final void jjAddStates(int start, int end)
191 {
192 do {
193 jjstateSet[jjnewStateCnt++] = jjnextStates[start];
194 } while (start++ != end);
195 }
196 private final void jjCheckNAddTwoStates(int state1, int state2)
197 {
198 jjCheckNAdd(state1);
199 jjCheckNAdd(state2);
200 }
201 private final void jjCheckNAddStates(int start, int end)
202 {
203 do {
204 jjCheckNAdd(jjnextStates[start]);
205 } while (start++ != end);
206 }
207 private final void jjCheckNAddStates(int start)
208 {
209 jjCheckNAdd(jjnextStates[start]);
210 jjCheckNAdd(jjnextStates[start + 1]);
211 }
212 static final long[] jjbitVec0 = {
213 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
214 };
215 static final long[] jjbitVec2 = {
216 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
217 };
218 private final int jjMoveNfa_0(int startState, int curPos)
219 {
220 int[] nextStates;
221 int startsAt = 0;
222 jjnewStateCnt = 61;
223 int i = 1;
224 jjstateSet[0] = startState;
225 int j, kind = 0x7fffffff;
226 for (;;)
227 {
228 if (++jjround == 0x7fffffff)
229 ReInitRounds();
230 if (curChar < 64)
231 {
232 long l = 1L << curChar;
233 MatchLoop: do
234 {
235 switch(jjstateSet[--i])
236 {
237 case 8:
238 if ((0x7800dcf200000000L & l) != 0L)
239 {
240 if (kind > 12)
241 kind = 12;
242 jjCheckNAdd(9);
243 }
244 else if ((0x3ff000000000000L & l) != 0L)
245 {
246 if (kind > 8)
247 kind = 8;
248 jjCheckNAddStates(0, 7);
249 }
250 else if (curChar == 58)
251 jjAddStates(8, 9);
252 else if (curChar == 34)
253 jjCheckNAddStates(10, 12);
254 if ((0x280000000000L & l) != 0L)
255 jjCheckNAddStates(13, 17);
256 else if (curChar == 46)
257 jjCheckNAdd(4);
258 else if (curChar == 48)
259 jjstateSet[jjnewStateCnt++] = 1;
260 break;
261 case 0:
262 if (curChar == 48)
263 jjstateSet[jjnewStateCnt++] = 1;
264 break;
265 case 2:
266 if ((0x3ff000000000000L & l) == 0L)
267 break;
268 if (kind > 9)
269 kind = 9;
270 jjstateSet[jjnewStateCnt++] = 2;
271 break;
272 case 3:
273 if (curChar == 46)
274 jjCheckNAdd(4);
275 break;
276 case 4:
277 if ((0x3ff000000000000L & l) == 0L)
278 break;
279 if (kind > 10)
280 kind = 10;
281 jjCheckNAddTwoStates(4, 5);
282 break;
283 case 6:
284 if ((0x280000000000L & l) != 0L)
285 jjCheckNAdd(7);
286 break;
287 case 7:
288 if ((0x3ff000000000000L & l) == 0L)
289 break;
290 if (kind > 10)
291 kind = 10;
292 jjCheckNAdd(7);
293 break;
294 case 9:
295 if ((0xfffffcfe00000000L & l) == 0L)
296 break;
297 if (kind > 12)
298 kind = 12;
299 jjCheckNAdd(9);
300 break;
301 case 10:
302 if (curChar == 34)
303 jjCheckNAddStates(10, 12);
304 break;
305 case 11:
306 if ((0xfffffffbffffdbffL & l) != 0L)
307 jjCheckNAddStates(10, 12);
308 break;
309 case 13:
310 if ((0x8400000000L & l) != 0L)
311 jjCheckNAddStates(10, 12);
312 break;
313 case 14:
314 if (curChar == 34 && kind > 13)
315 kind = 13;
316 break;
317 case 15:
318 if ((0xff000000000000L & l) != 0L)
319 jjCheckNAddStates(18, 21);
320 break;
321 case 16:
322 if ((0xff000000000000L & l) != 0L)
323 jjCheckNAddStates(10, 12);
324 break;
325 case 17:
326 if ((0xf000000000000L & l) != 0L)
327 jjstateSet[jjnewStateCnt++] = 18;
328 break;
329 case 18:
330 if ((0xff000000000000L & l) != 0L)
331 jjCheckNAdd(16);
332 break;
333 case 19:
334 if (curChar == 58)
335 jjAddStates(8, 9);
336 break;
337 case 20:
338 if ((0x7800dcf200000000L & l) == 0L)
339 break;
340 if (kind > 14)
341 kind = 14;
342 jjCheckNAdd(21);
343 break;
344 case 21:
345 if ((0xfffffcfe00000000L & l) == 0L)
346 break;
347 if (kind > 14)
348 kind = 14;
349 jjCheckNAdd(21);
350 break;
351 case 22:
352 if (curChar == 34)
353 jjCheckNAddStates(22, 24);
354 break;
355 case 23:
356 if ((0xfffffffbffffdbffL & l) != 0L)
357 jjCheckNAddStates(22, 24);
358 break;
359 case 25:
360 if ((0x8400000000L & l) != 0L)
361 jjCheckNAddStates(22, 24);
362 break;
363 case 26:
364 if (curChar == 34 && kind > 14)
365 kind = 14;
366 break;
367 case 27:
368 if ((0xff000000000000L & l) != 0L)
369 jjCheckNAddStates(25, 28);
370 break;
371 case 28:
372 if ((0xff000000000000L & l) != 0L)
373 jjCheckNAddStates(22, 24);
374 break;
375 case 29:
376 if ((0xf000000000000L & l) != 0L)
377 jjstateSet[jjnewStateCnt++] = 30;
378 break;
379 case 30:
380 if ((0xff000000000000L & l) != 0L)
381 jjCheckNAdd(28);
382 break;
383 case 31:
384 if ((0x280000000000L & l) != 0L)
385 jjCheckNAddStates(13, 17);
386 break;
387 case 32:
388 if ((0x3ff000000000000L & l) == 0L)
389 break;
390 if (kind > 8)
391 kind = 8;
392 jjCheckNAdd(32);
393 break;
394 case 33:
395 if ((0x3ff000000000000L & l) != 0L)
396 jjCheckNAddTwoStates(33, 34);
397 break;
398 case 35:
399 if ((0x280000000000L & l) != 0L)
400 jjCheckNAdd(36);
401 break;
402 case 36:
403 if ((0x3ff000000000000L & l) == 0L)
404 break;
405 if (kind > 11)
406 kind = 11;
407 jjCheckNAdd(36);
408 break;
409 case 37:
410 if ((0x3ff000000000000L & l) != 0L)
411 jjCheckNAddStates(29, 32);
412 break;
413 case 38:
414 if ((0x3ff000000000000L & l) != 0L)
415 jjCheckNAddTwoStates(38, 39);
416 break;
417 case 39:
418 if (curChar != 46)
419 break;
420 if (kind > 10)
421 kind = 10;
422 jjCheckNAddTwoStates(40, 5);
423 break;
424 case 40:
425 if ((0x3ff000000000000L & l) == 0L)
426 break;
427 if (kind > 10)
428 kind = 10;
429 jjCheckNAddTwoStates(40, 5);
430 break;
431 case 41:
432 if ((0x3ff000000000000L & l) != 0L)
433 jjCheckNAddTwoStates(41, 3);
434 break;
435 case 42:
436 if ((0x3ff000000000000L & l) == 0L)
437 break;
438 if (kind > 8)
439 kind = 8;
440 jjCheckNAddStates(0, 7);
441 break;
442 case 43:
443 if ((0x3ff000000000000L & l) != 0L)
444 jjstateSet[jjnewStateCnt++] = 44;
445 break;
446 case 44:
447 if ((0x3ff000000000000L & l) != 0L)
448 jjstateSet[jjnewStateCnt++] = 45;
449 break;
450 case 45:
451 if ((0x3ff000000000000L & l) != 0L)
452 jjstateSet[jjnewStateCnt++] = 46;
453 break;
454 case 46:
455 if ((0x3ff000000000000L & l) != 0L)
456 jjstateSet[jjnewStateCnt++] = 47;
457 break;
458 case 47:
459 if ((0x3ff000000000000L & l) != 0L)
460 jjstateSet[jjnewStateCnt++] = 48;
461 break;
462 case 48:
463 if ((0x3ff000000000000L & l) != 0L)
464 jjstateSet[jjnewStateCnt++] = 49;
465 break;
466 case 49:
467 if ((0x3ff000000000000L & l) != 0L)
468 jjstateSet[jjnewStateCnt++] = 50;
469 break;
470 case 51:
471 if ((0x3ff000000000000L & l) != 0L)
472 jjstateSet[jjnewStateCnt++] = 52;
473 break;
474 case 52:
475 if ((0x3ff000000000000L & l) != 0L)
476 jjstateSet[jjnewStateCnt++] = 53;
477 break;
478 case 53:
479 if ((0x3ff000000000000L & l) != 0L)
480 jjstateSet[jjnewStateCnt++] = 54;
481 break;
482 case 54:
483 if ((0x3ff000000000000L & l) != 0L)
484 jjstateSet[jjnewStateCnt++] = 55;
485 break;
486 case 55:
487 if ((0x3ff000000000000L & l) != 0L)
488 jjstateSet[jjnewStateCnt++] = 56;
489 break;
490 case 56:
491 if ((0x3ff000000000000L & l) != 0L)
492 jjstateSet[jjnewStateCnt++] = 57;
493 break;
494 case 57:
495 if ((0x3ff000000000000L & l) != 0L)
496 jjstateSet[jjnewStateCnt++] = 58;
497 break;
498 case 58:
499 if ((0x3ff000000000000L & l) != 0L)
500 jjstateSet[jjnewStateCnt++] = 59;
501 break;
502 case 59:
503 if ((0x3ff000000000000L & l) == 0L)
504 break;
505 if (kind > 15)
506 kind = 15;
507 jjstateSet[jjnewStateCnt++] = 60;
508 break;
509 default : break;
510 }
511 } while(i != startsAt);
512 }
513 else if (curChar < 128)
514 {
515 long l = 1L << (curChar & 077);
516 MatchLoop: do
517 {
518 switch(jjstateSet[--i])
519 {
520 case 8:
521 case 9:
522 if (kind > 12)
523 kind = 12;
524 jjCheckNAdd(9);
525 break;
526 case 1:
527 if ((0x100000001000000L & l) != 0L)
528 jjCheckNAdd(2);
529 break;
530 case 2:
531 if ((0x7e0000007eL & l) == 0L)
532 break;
533 if (kind > 9)
534 kind = 9;
535 jjCheckNAdd(2);
536 break;
537 case 5:
538 if ((0x2000000020L & l) != 0L)
539 jjAddStates(33, 34);
540 break;
541 case 11:
542 if ((0xffffffffefffffffL & l) != 0L)
543 jjCheckNAddStates(10, 12);
544 break;
545 case 12:
546 if (curChar == 92)
547 jjAddStates(35, 37);
548 break;
549 case 13:
550 if ((0x14404410000000L & l) != 0L)
551 jjCheckNAddStates(10, 12);
552 break;
553 case 20:
554 case 21:
555 if (kind > 14)
556 kind = 14;
557 jjCheckNAdd(21);
558 break;
559 case 23:
560 if ((0xffffffffefffffffL & l) != 0L)
561 jjCheckNAddStates(22, 24);
562 break;
563 case 24:
564 if (curChar == 92)
565 jjAddStates(38, 40);
566 break;
567 case 25:
568 if ((0x14404410000000L & l) != 0L)
569 jjCheckNAddStates(22, 24);
570 break;
571 case 34:
572 if ((0x2000000020L & l) != 0L)
573 jjAddStates(41, 42);
574 break;
575 case 50:
576 if ((0x10000000100000L & l) != 0L)
577 jjstateSet[jjnewStateCnt++] = 51;
578 break;
579 case 60:
580 if ((0x7fffffe07fffffeL & l) != 0L && kind > 15)
581 kind = 15;
582 break;
583 default : break;
584 }
585 } while(i != startsAt);
586 }
587 else
588 {
589 int hiByte = (int)(curChar >> 8);
590 int i1 = hiByte >> 6;
591 long l1 = 1L << (hiByte & 077);
592 int i2 = (curChar & 0xff) >> 6;
593 long l2 = 1L << (curChar & 077);
594 MatchLoop: do
595 {
596 switch(jjstateSet[--i])
597 {
598 case 8:
599 case 9:
600 if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
601 break;
602 if (kind > 12)
603 kind = 12;
604 jjCheckNAdd(9);
605 break;
606 case 11:
607 if (jjCanMove_0(hiByte, i1, i2, l1, l2))
608 jjAddStates(10, 12);
609 break;
610 case 20:
611 case 21:
612 if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
613 break;
614 if (kind > 14)
615 kind = 14;
616 jjCheckNAdd(21);
617 break;
618 case 23:
619 if (jjCanMove_0(hiByte, i1, i2, l1, l2))
620 jjAddStates(22, 24);
621 break;
622 default : break;
623 }
624 } while(i != startsAt);
625 }
626 if (kind != 0x7fffffff)
627 {
628 jjmatchedKind = kind;
629 jjmatchedPos = curPos;
630 kind = 0x7fffffff;
631 }
632 ++curPos;
633 if ((i = jjnewStateCnt) == (startsAt = 61 - (jjnewStateCnt = startsAt)))
634 return curPos;
635 try { curChar = input_stream.readChar(); }
636 catch(java.io.IOException e) { return curPos; }
637 }
638 }
639 static final int[] jjnextStates = {
640 32, 38, 39, 41, 3, 33, 34, 43, 20, 22, 11, 12, 14, 32, 0, 3,
641 33, 37, 11, 12, 16, 14, 23, 24, 26, 23, 24, 28, 26, 38, 39, 41,
642 3, 6, 7, 13, 15, 17, 25, 27, 29, 35, 36,
643 };
644 private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
645 {
646 switch(hiByte)
647 {
648 case 0:
649 return ((jjbitVec2[i2] & l2) != 0L);
650 default :
651 if ((jjbitVec0[i1] & l1) != 0L)
652 return true;
653 return false;
654 }
655 }
656 public static final String[] jjstrLiteralImages = {
657 "", null, null, null, null, "\50", "\51", "\141\143\164\151\157\156", null,
658 null, null, null, null, null, null, null, };
659 public static final String[] lexStateNames = {
660 "DEFAULT",
661 };
662 static final long[] jjtoToken = {
663 0xffe1L,
664 };
665 static final long[] jjtoSkip = {
666 0x1eL,
667 };
668 private ASCII_UCodeESC_CharStream input_stream;
669 private final int[] jjrounds = new int[61];
670 private final int[] jjstateSet = new int[122];
671 protected char curChar;
672 public SL0ParserTokenManager(ASCII_UCodeESC_CharStream stream)
673 {
674 if (ASCII_UCodeESC_CharStream.staticFlag)
675 throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
676 input_stream = stream;
677 }
678 public SL0ParserTokenManager(ASCII_UCodeESC_CharStream stream, int lexState)
679 {
680 this(stream);
681 SwitchTo(lexState);
682 }
683 public void ReInit(ASCII_UCodeESC_CharStream stream)
684 {
685 jjmatchedPos = jjnewStateCnt = 0;
686 curLexState = defaultLexState;
687 input_stream = stream;
688 ReInitRounds();
689 }
690 private final void ReInitRounds()
691 {
692 int i;
693 jjround = 0x80000001;
694 for (i = 61; i-- > 0;)
695 jjrounds[i] = 0x80000000;
696 }
697 public void ReInit(ASCII_UCodeESC_CharStream stream, int lexState)
698 {
699 ReInit(stream);
700 SwitchTo(lexState);
701 }
702 public void SwitchTo(int lexState)
703 {
704 if (lexState >= 1 || lexState < 0)
705 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
706 else
707 curLexState = lexState;
708 }
709
710 private final Token jjFillToken()
711 {
712 Token t = Token.newToken(jjmatchedKind);
713 t.kind = jjmatchedKind;
714 String im = jjstrLiteralImages[jjmatchedKind];
715 t.image = (im == null) ? input_stream.GetImage() : im;
716 t.beginLine = input_stream.getBeginLine();
717 t.beginColumn = input_stream.getBeginColumn();
718 t.endLine = input_stream.getEndLine();
719 t.endColumn = input_stream.getEndColumn();
720 return t;
721 }
722
723 int curLexState = 0;
724 int defaultLexState = 0;
725 int jjnewStateCnt;
726 int jjround;
727 int jjmatchedPos;
728 int jjmatchedKind;
729
730 public final Token getNextToken()
731 {
732 int kind;
733 Token specialToken = null;
734 Token matchedToken;
735 int curPos = 0;
736
737 EOFLoop :
738 for (;;)
739 {
740 try
741 {
742 curChar = input_stream.BeginToken();
743 }
744 catch(java.io.IOException e)
745 {
746 jjmatchedKind = 0;
747 matchedToken = jjFillToken();
748 return matchedToken;
749 }
750
751 try { input_stream.backup(0);
752 while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
753 curChar = input_stream.BeginToken();
754 }
755 catch (java.io.IOException e1) { continue EOFLoop; }
756 jjmatchedKind = 0x7fffffff;
757 jjmatchedPos = 0;
758 curPos = jjMoveStringLiteralDfa0_0();
759 if (jjmatchedKind != 0x7fffffff)
760 {
761 if (jjmatchedPos + 1 < curPos)
762 input_stream.backup(curPos - jjmatchedPos - 1);
763 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
764 {
765 matchedToken = jjFillToken();
766 return matchedToken;
767 }
768 else
769 {
770 continue EOFLoop;
771 }
772 }
773 int error_line = input_stream.getEndLine();
774 int error_column = input_stream.getEndColumn();
775 String error_after = null;
776 boolean EOFSeen = false;
777 try { input_stream.readChar(); input_stream.backup(1); }
778 catch (java.io.IOException e1) {
779 EOFSeen = true;
780 error_after = curPos <= 1 ? "" : input_stream.GetImage();
781 if (curChar == '\n' || curChar == '\r') {
782 error_line++;
783 error_column = 0;
784 }
785 else
786 error_column++;
787 }
788 if (!EOFSeen) {
789 input_stream.backup(1);
790 error_after = curPos <= 1 ? "" : input_stream.GetImage();
791 }
792 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
793 }
794 }
795
796 }