001: /* Generated By:JavaCC: Do not edit this line. JDOQLTokenManager.java */
002: package org.xorm.query.jdoql;
003:
004: import java.io.IOException;
005: import java.io.StringReader;
006: import java.util.HashMap;
007: import java.util.Map;
008: import java.util.Stack;
009: import org.xorm.query.*;
010:
011: public class JDOQLTokenManager implements JDOQLConstants {
012: public java.io.PrintStream debugStream = System.out;
013:
014: public void setDebugStream(java.io.PrintStream ds) {
015: debugStream = ds;
016: }
017:
018: private final int jjStopStringLiteralDfa_0(int pos, long active0) {
019: switch (pos) {
020: case 0:
021: if ((active0 & 0x8000000L) != 0L)
022: return 6;
023: if ((active0 & 0x10000000L) != 0L)
024: return 32;
025: if ((active0 & 0x1e0000L) != 0L) {
026: jjmatchedKind = 21;
027: return 1;
028: }
029: return -1;
030: case 1:
031: if ((active0 & 0x1e0000L) != 0L) {
032: jjmatchedKind = 21;
033: jjmatchedPos = 1;
034: return 1;
035: }
036: return -1;
037: case 2:
038: if ((active0 & 0x1e0000L) != 0L) {
039: jjmatchedKind = 21;
040: jjmatchedPos = 2;
041: return 1;
042: }
043: return -1;
044: case 3:
045: if ((active0 & 0x160000L) != 0L)
046: return 1;
047: if ((active0 & 0x80000L) != 0L) {
048: jjmatchedKind = 21;
049: jjmatchedPos = 3;
050: return 1;
051: }
052: return -1;
053: default:
054: return -1;
055: }
056: }
057:
058: private final int jjStartNfa_0(int pos, long active0) {
059: return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0),
060: pos + 1);
061: }
062:
063: private final int jjStopAtPos(int pos, int kind) {
064: jjmatchedKind = kind;
065: jjmatchedPos = pos;
066: return pos + 1;
067: }
068:
069: private final int jjStartNfaWithStates_0(int pos, int kind,
070: int state) {
071: jjmatchedKind = kind;
072: jjmatchedPos = pos;
073: try {
074: curChar = input_stream.readChar();
075: } catch (java.io.IOException e) {
076: return pos + 1;
077: }
078: return jjMoveNfa_0(state, pos + 1);
079: }
080:
081: private final int jjMoveStringLiteralDfa0_0() {
082: switch (curChar) {
083: case 10:
084: return jjStopAtPos(0, 32);
085: case 33:
086: jjmatchedKind = 16;
087: return jjMoveStringLiteralDfa1_0(0x20L);
088: case 38:
089: jjmatchedKind = 11;
090: return jjMoveStringLiteralDfa1_0(0x400L);
091: case 40:
092: return jjStopAtPos(0, 25);
093: case 41:
094: return jjStopAtPos(0, 26);
095: case 42:
096: return jjStopAtPos(0, 30);
097: case 43:
098: return jjStopAtPos(0, 29);
099: case 44:
100: return jjStopAtPos(0, 33);
101: case 45:
102: return jjStartNfaWithStates_0(0, 28, 32);
103: case 46:
104: return jjStartNfaWithStates_0(0, 27, 6);
105: case 47:
106: return jjStopAtPos(0, 31);
107: case 60:
108: jjmatchedKind = 7;
109: return jjMoveStringLiteralDfa1_0(0x200L);
110: case 61:
111: return jjMoveStringLiteralDfa1_0(0x10L);
112: case 62:
113: jjmatchedKind = 6;
114: return jjMoveStringLiteralDfa1_0(0x100L);
115: case 94:
116: return jjStopAtPos(0, 14);
117: case 102:
118: return jjMoveStringLiteralDfa1_0(0x80000L);
119: case 110:
120: return jjMoveStringLiteralDfa1_0(0x20000L);
121: case 116:
122: return jjMoveStringLiteralDfa1_0(0x140000L);
123: case 124:
124: jjmatchedKind = 13;
125: return jjMoveStringLiteralDfa1_0(0x1000L);
126: case 126:
127: return jjStopAtPos(0, 15);
128: default:
129: return jjMoveNfa_0(0, 0);
130: }
131: }
132:
133: private final int jjMoveStringLiteralDfa1_0(long active0) {
134: try {
135: curChar = input_stream.readChar();
136: } catch (java.io.IOException e) {
137: jjStopStringLiteralDfa_0(0, active0);
138: return 1;
139: }
140: switch (curChar) {
141: case 38:
142: if ((active0 & 0x400L) != 0L)
143: return jjStopAtPos(1, 10);
144: break;
145: case 61:
146: if ((active0 & 0x10L) != 0L)
147: return jjStopAtPos(1, 4);
148: else if ((active0 & 0x20L) != 0L)
149: return jjStopAtPos(1, 5);
150: else if ((active0 & 0x100L) != 0L)
151: return jjStopAtPos(1, 8);
152: else if ((active0 & 0x200L) != 0L)
153: return jjStopAtPos(1, 9);
154: break;
155: case 97:
156: return jjMoveStringLiteralDfa2_0(active0, 0x80000L);
157: case 104:
158: return jjMoveStringLiteralDfa2_0(active0, 0x100000L);
159: case 114:
160: return jjMoveStringLiteralDfa2_0(active0, 0x40000L);
161: case 117:
162: return jjMoveStringLiteralDfa2_0(active0, 0x20000L);
163: case 124:
164: if ((active0 & 0x1000L) != 0L)
165: return jjStopAtPos(1, 12);
166: break;
167: default:
168: break;
169: }
170: return jjStartNfa_0(0, active0);
171: }
172:
173: private final int jjMoveStringLiteralDfa2_0(long old0, long active0) {
174: if (((active0 &= old0)) == 0L)
175: return jjStartNfa_0(0, old0);
176: try {
177: curChar = input_stream.readChar();
178: } catch (java.io.IOException e) {
179: jjStopStringLiteralDfa_0(1, active0);
180: return 2;
181: }
182: switch (curChar) {
183: case 105:
184: return jjMoveStringLiteralDfa3_0(active0, 0x100000L);
185: case 108:
186: return jjMoveStringLiteralDfa3_0(active0, 0xa0000L);
187: case 117:
188: return jjMoveStringLiteralDfa3_0(active0, 0x40000L);
189: default:
190: break;
191: }
192: return jjStartNfa_0(1, active0);
193: }
194:
195: private final int jjMoveStringLiteralDfa3_0(long old0, long active0) {
196: if (((active0 &= old0)) == 0L)
197: return jjStartNfa_0(1, old0);
198: try {
199: curChar = input_stream.readChar();
200: } catch (java.io.IOException e) {
201: jjStopStringLiteralDfa_0(2, active0);
202: return 3;
203: }
204: switch (curChar) {
205: case 101:
206: if ((active0 & 0x40000L) != 0L)
207: return jjStartNfaWithStates_0(3, 18, 1);
208: break;
209: case 108:
210: if ((active0 & 0x20000L) != 0L)
211: return jjStartNfaWithStates_0(3, 17, 1);
212: break;
213: case 115:
214: if ((active0 & 0x100000L) != 0L)
215: return jjStartNfaWithStates_0(3, 20, 1);
216: return jjMoveStringLiteralDfa4_0(active0, 0x80000L);
217: default:
218: break;
219: }
220: return jjStartNfa_0(2, active0);
221: }
222:
223: private final int jjMoveStringLiteralDfa4_0(long old0, long active0) {
224: if (((active0 &= old0)) == 0L)
225: return jjStartNfa_0(2, old0);
226: try {
227: curChar = input_stream.readChar();
228: } catch (java.io.IOException e) {
229: jjStopStringLiteralDfa_0(3, active0);
230: return 4;
231: }
232: switch (curChar) {
233: case 101:
234: if ((active0 & 0x80000L) != 0L)
235: return jjStartNfaWithStates_0(4, 19, 1);
236: break;
237: default:
238: break;
239: }
240: return jjStartNfa_0(3, active0);
241: }
242:
243: private final void jjCheckNAdd(int state) {
244: if (jjrounds[state] != jjround) {
245: jjstateSet[jjnewStateCnt++] = state;
246: jjrounds[state] = jjround;
247: }
248: }
249:
250: private final void jjAddStates(int start, int end) {
251: do {
252: jjstateSet[jjnewStateCnt++] = jjnextStates[start];
253: } while (start++ != end);
254: }
255:
256: private final void jjCheckNAddTwoStates(int state1, int state2) {
257: jjCheckNAdd(state1);
258: jjCheckNAdd(state2);
259: }
260:
261: private final void jjCheckNAddStates(int start, int end) {
262: do {
263: jjCheckNAdd(jjnextStates[start]);
264: } while (start++ != end);
265: }
266:
267: private final void jjCheckNAddStates(int start) {
268: jjCheckNAdd(jjnextStates[start]);
269: jjCheckNAdd(jjnextStates[start + 1]);
270: }
271:
272: static final long[] jjbitVec0 = { 0x0L, 0x0L, 0xffffffffffffffffL,
273: 0xffffffffffffffffL };
274:
275: private final int jjMoveNfa_0(int startState, int curPos) {
276: int[] nextStates;
277: int startsAt = 0;
278: jjnewStateCnt = 48;
279: int i = 1;
280: jjstateSet[0] = startState;
281: int j, kind = 0x7fffffff;
282: for (;;) {
283: if (++jjround == 0x7fffffff)
284: ReInitRounds();
285: if (curChar < 64) {
286: long l = 1L << curChar;
287: MatchLoop: do {
288: switch (jjstateSet[--i]) {
289: case 32:
290: if ((0x3ff000000000000L & l) != 0L)
291: jjCheckNAddStates(0, 6);
292: else if (curChar == 46)
293: jjCheckNAdd(6);
294: if ((0x3ff000000000000L & l) != 0L) {
295: if (kind > 37)
296: kind = 37;
297: jjCheckNAddTwoStates(30, 31);
298: }
299: break;
300: case 0:
301: if ((0x3ff000000000000L & l) != 0L) {
302: if (kind > 37)
303: kind = 37;
304: jjCheckNAddStates(7, 15);
305: } else if (curChar == 45)
306: jjCheckNAddStates(16, 18);
307: else if (curChar == 34)
308: jjCheckNAddStates(19, 21);
309: else if (curChar == 39)
310: jjAddStates(22, 23);
311: else if (curChar == 46)
312: jjCheckNAdd(6);
313: break;
314: case 1:
315: if ((0x3ff000000000000L & l) == 0L)
316: break;
317: if (kind > 21)
318: kind = 21;
319: jjstateSet[jjnewStateCnt++] = 1;
320: break;
321: case 5:
322: if (curChar == 46)
323: jjCheckNAdd(6);
324: break;
325: case 6:
326: if ((0x3ff000000000000L & l) == 0L)
327: break;
328: if (kind > 39)
329: kind = 39;
330: jjCheckNAddStates(24, 26);
331: break;
332: case 8:
333: if ((0x280000000000L & l) != 0L)
334: jjCheckNAdd(9);
335: break;
336: case 9:
337: if ((0x3ff000000000000L & l) == 0L)
338: break;
339: if (kind > 39)
340: kind = 39;
341: jjCheckNAddTwoStates(9, 10);
342: break;
343: case 11:
344: if (curChar == 39)
345: jjAddStates(22, 23);
346: break;
347: case 12:
348: if ((0xffffff7fffffdbffL & l) != 0L)
349: jjCheckNAdd(13);
350: break;
351: case 13:
352: if (curChar == 39 && kind > 41)
353: kind = 41;
354: break;
355: case 15:
356: if ((0x8400000000L & l) != 0L)
357: jjCheckNAdd(13);
358: break;
359: case 16:
360: if ((0xff000000000000L & l) != 0L)
361: jjCheckNAddTwoStates(17, 13);
362: break;
363: case 17:
364: if ((0xff000000000000L & l) != 0L)
365: jjCheckNAdd(13);
366: break;
367: case 18:
368: if ((0xf000000000000L & l) != 0L)
369: jjstateSet[jjnewStateCnt++] = 19;
370: break;
371: case 19:
372: if ((0xff000000000000L & l) != 0L)
373: jjCheckNAdd(17);
374: break;
375: case 20:
376: if (curChar == 34)
377: jjCheckNAddStates(19, 21);
378: break;
379: case 21:
380: if ((0xfffffffbffffdbffL & l) != 0L)
381: jjCheckNAddStates(19, 21);
382: break;
383: case 23:
384: if ((0x8400000000L & l) != 0L)
385: jjCheckNAddStates(19, 21);
386: break;
387: case 24:
388: if (curChar == 34 && kind > 42)
389: kind = 42;
390: break;
391: case 25:
392: if ((0xff000000000000L & l) != 0L)
393: jjCheckNAddStates(27, 30);
394: break;
395: case 26:
396: if ((0xff000000000000L & l) != 0L)
397: jjCheckNAddStates(19, 21);
398: break;
399: case 27:
400: if ((0xf000000000000L & l) != 0L)
401: jjstateSet[jjnewStateCnt++] = 28;
402: break;
403: case 28:
404: if ((0xff000000000000L & l) != 0L)
405: jjCheckNAdd(26);
406: break;
407: case 29:
408: if (curChar == 45)
409: jjCheckNAddStates(16, 18);
410: break;
411: case 30:
412: if ((0x3ff000000000000L & l) == 0L)
413: break;
414: if (kind > 37)
415: kind = 37;
416: jjCheckNAddTwoStates(30, 31);
417: break;
418: case 33:
419: if ((0x3ff000000000000L & l) != 0L)
420: jjCheckNAddTwoStates(33, 34);
421: break;
422: case 34:
423: if (curChar != 46)
424: break;
425: if (kind > 39)
426: kind = 39;
427: jjCheckNAddStates(31, 33);
428: break;
429: case 35:
430: if ((0x3ff000000000000L & l) == 0L)
431: break;
432: if (kind > 39)
433: kind = 39;
434: jjCheckNAddStates(31, 33);
435: break;
436: case 37:
437: if ((0x280000000000L & l) != 0L)
438: jjCheckNAdd(38);
439: break;
440: case 38:
441: if ((0x3ff000000000000L & l) == 0L)
442: break;
443: if (kind > 39)
444: kind = 39;
445: jjCheckNAddTwoStates(38, 10);
446: break;
447: case 39:
448: if ((0x3ff000000000000L & l) != 0L)
449: jjCheckNAddTwoStates(39, 40);
450: break;
451: case 41:
452: if ((0x280000000000L & l) != 0L)
453: jjCheckNAdd(42);
454: break;
455: case 42:
456: if ((0x3ff000000000000L & l) == 0L)
457: break;
458: if (kind > 39)
459: kind = 39;
460: jjCheckNAddTwoStates(42, 10);
461: break;
462: case 43:
463: if ((0x3ff000000000000L & l) != 0L)
464: jjCheckNAddStates(34, 36);
465: break;
466: case 45:
467: if ((0x280000000000L & l) != 0L)
468: jjCheckNAdd(46);
469: break;
470: case 46:
471: if ((0x3ff000000000000L & l) != 0L)
472: jjCheckNAddTwoStates(46, 10);
473: break;
474: case 47:
475: if ((0x3ff000000000000L & l) == 0L)
476: break;
477: if (kind > 37)
478: kind = 37;
479: jjCheckNAddStates(7, 15);
480: break;
481: default:
482: break;
483: }
484: } while (i != startsAt);
485: } else if (curChar < 128) {
486: long l = 1L << (curChar & 077);
487: MatchLoop: do {
488: switch (jjstateSet[--i]) {
489: case 0:
490: if ((0x7fffffe87fffffeL & l) != 0L) {
491: if (kind > 21)
492: kind = 21;
493: jjCheckNAdd(1);
494: }
495: if ((0x1000000010L & l) != 0L) {
496: if (kind > 36)
497: kind = 36;
498: } else if ((0x4000000040L & l) != 0L) {
499: if (kind > 35)
500: kind = 35;
501: } else if ((0x100000001000L & l) != 0L) {
502: if (kind > 34)
503: kind = 34;
504: }
505: break;
506: case 1:
507: if ((0x7fffffe87fffffeL & l) == 0L)
508: break;
509: if (kind > 21)
510: kind = 21;
511: jjCheckNAdd(1);
512: break;
513: case 2:
514: if ((0x100000001000L & l) != 0L && kind > 34)
515: kind = 34;
516: break;
517: case 3:
518: if ((0x4000000040L & l) != 0L && kind > 35)
519: kind = 35;
520: break;
521: case 4:
522: if ((0x1000000010L & l) != 0L && kind > 36)
523: kind = 36;
524: break;
525: case 7:
526: if ((0x2000000020L & l) != 0L)
527: jjAddStates(37, 38);
528: break;
529: case 10:
530: if ((0x5000000050L & l) != 0L && kind > 39)
531: kind = 39;
532: break;
533: case 12:
534: if ((0xffffffffefffffffL & l) != 0L)
535: jjCheckNAdd(13);
536: break;
537: case 14:
538: if (curChar == 92)
539: jjAddStates(39, 41);
540: break;
541: case 15:
542: if ((0x14404410000000L & l) != 0L)
543: jjCheckNAdd(13);
544: break;
545: case 21:
546: if ((0xffffffffefffffffL & l) != 0L)
547: jjCheckNAddStates(19, 21);
548: break;
549: case 22:
550: if (curChar == 92)
551: jjAddStates(42, 44);
552: break;
553: case 23:
554: if ((0x14404410000000L & l) != 0L)
555: jjCheckNAddStates(19, 21);
556: break;
557: case 31:
558: if ((0x100000001000L & l) != 0L && kind > 37)
559: kind = 37;
560: break;
561: case 36:
562: if ((0x2000000020L & l) != 0L)
563: jjAddStates(45, 46);
564: break;
565: case 40:
566: if ((0x2000000020L & l) != 0L)
567: jjAddStates(47, 48);
568: break;
569: case 44:
570: if ((0x2000000020L & l) != 0L)
571: jjAddStates(49, 50);
572: break;
573: default:
574: break;
575: }
576: } while (i != startsAt);
577: } else {
578: int i2 = (curChar & 0xff) >> 6;
579: long l2 = 1L << (curChar & 077);
580: MatchLoop: do {
581: switch (jjstateSet[--i]) {
582: case 12:
583: if ((jjbitVec0[i2] & l2) != 0L)
584: jjstateSet[jjnewStateCnt++] = 13;
585: break;
586: case 21:
587: if ((jjbitVec0[i2] & l2) != 0L)
588: jjAddStates(19, 21);
589: break;
590: default:
591: break;
592: }
593: } while (i != startsAt);
594: }
595: if (kind != 0x7fffffff) {
596: jjmatchedKind = kind;
597: jjmatchedPos = curPos;
598: kind = 0x7fffffff;
599: }
600: ++curPos;
601: if ((i = jjnewStateCnt) == (startsAt = 48 - (jjnewStateCnt = startsAt)))
602: return curPos;
603: try {
604: curChar = input_stream.readChar();
605: } catch (java.io.IOException e) {
606: return curPos;
607: }
608: }
609: }
610:
611: static final int[] jjnextStates = { 33, 34, 39, 40, 43, 44, 10, 30,
612: 31, 33, 34, 39, 40, 43, 44, 10, 30, 5, 32, 21, 22, 24, 12,
613: 14, 6, 7, 10, 21, 22, 26, 24, 35, 36, 10, 43, 44, 10, 8, 9,
614: 15, 16, 18, 23, 25, 27, 37, 38, 41, 42, 45, 46, };
615: public static final String[] jjstrLiteralImages = { "", null, null,
616: null, "\75\75", "\41\75", "\76", "\74", "\76\75", "\74\75",
617: "\46\46", "\46", "\174\174", "\174", "\136", "\176", "\41",
618: "\156\165\154\154", "\164\162\165\145",
619: "\146\141\154\163\145", "\164\150\151\163", null, null,
620: null, null, "\50", "\51", "\56", "\55", "\53", "\52",
621: "\57", "\12", "\54", null, null, null, null, null, null,
622: null, null, null, };
623: public static final String[] lexStateNames = { "DEFAULT", };
624: static final long[] jjtoToken = { 0x6bffe3ffff1L, };
625: static final long[] jjtoSkip = { 0xeL, };
626: private SimpleCharStream input_stream;
627: private final int[] jjrounds = new int[48];
628: private final int[] jjstateSet = new int[96];
629: protected char curChar;
630:
631: public JDOQLTokenManager(SimpleCharStream stream) {
632: if (SimpleCharStream.staticFlag)
633: throw new Error(
634: "ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
635: input_stream = stream;
636: }
637:
638: public JDOQLTokenManager(SimpleCharStream stream, int lexState) {
639: this (stream);
640: SwitchTo(lexState);
641: }
642:
643: public void ReInit(SimpleCharStream stream) {
644: jjmatchedPos = jjnewStateCnt = 0;
645: curLexState = defaultLexState;
646: input_stream = stream;
647: ReInitRounds();
648: }
649:
650: private final void ReInitRounds() {
651: int i;
652: jjround = 0x80000001;
653: for (i = 48; i-- > 0;)
654: jjrounds[i] = 0x80000000;
655: }
656:
657: public void ReInit(SimpleCharStream stream, int lexState) {
658: ReInit(stream);
659: SwitchTo(lexState);
660: }
661:
662: public void SwitchTo(int lexState) {
663: if (lexState >= 1 || lexState < 0)
664: throw new TokenMgrError(
665: "Error: Ignoring invalid lexical state : "
666: + lexState + ". State unchanged.",
667: TokenMgrError.INVALID_LEXICAL_STATE);
668: else
669: curLexState = lexState;
670: }
671:
672: private final Token jjFillToken() {
673: Token t = Token.newToken(jjmatchedKind);
674: t.kind = jjmatchedKind;
675: String im = jjstrLiteralImages[jjmatchedKind];
676: t.image = (im == null) ? input_stream.GetImage() : im;
677: t.beginLine = input_stream.getBeginLine();
678: t.beginColumn = input_stream.getBeginColumn();
679: t.endLine = input_stream.getEndLine();
680: t.endColumn = input_stream.getEndColumn();
681: return t;
682: }
683:
684: int curLexState = 0;
685: int defaultLexState = 0;
686: int jjnewStateCnt;
687: int jjround;
688: int jjmatchedPos;
689: int jjmatchedKind;
690:
691: public final Token getNextToken() {
692: int kind;
693: Token specialToken = null;
694: Token matchedToken;
695: int curPos = 0;
696:
697: EOFLoop: for (;;) {
698: try {
699: curChar = input_stream.BeginToken();
700: } catch (java.io.IOException e) {
701: jjmatchedKind = 0;
702: matchedToken = jjFillToken();
703: return matchedToken;
704: }
705:
706: try {
707: input_stream.backup(0);
708: while (curChar <= 32
709: && (0x100002200L & (1L << curChar)) != 0L)
710: curChar = input_stream.BeginToken();
711: } catch (java.io.IOException e1) {
712: continue EOFLoop;
713: }
714: jjmatchedKind = 0x7fffffff;
715: jjmatchedPos = 0;
716: curPos = jjMoveStringLiteralDfa0_0();
717: if (jjmatchedKind != 0x7fffffff) {
718: if (jjmatchedPos + 1 < curPos)
719: input_stream.backup(curPos - jjmatchedPos - 1);
720: if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
721: matchedToken = jjFillToken();
722: return matchedToken;
723: } else {
724: continue EOFLoop;
725: }
726: }
727: int error_line = input_stream.getEndLine();
728: int error_column = input_stream.getEndColumn();
729: String error_after = null;
730: boolean EOFSeen = false;
731: try {
732: input_stream.readChar();
733: input_stream.backup(1);
734: } catch (java.io.IOException e1) {
735: EOFSeen = true;
736: error_after = curPos <= 1 ? "" : input_stream
737: .GetImage();
738: if (curChar == '\n' || curChar == '\r') {
739: error_line++;
740: error_column = 0;
741: } else
742: error_column++;
743: }
744: if (!EOFSeen) {
745: input_stream.backup(1);
746: error_after = curPos <= 1 ? "" : input_stream
747: .GetImage();
748: }
749: throw new TokenMgrError(EOFSeen, curLexState, error_line,
750: error_column, error_after, curChar,
751: TokenMgrError.LEXICAL_ERROR);
752: }
753: }
754:
755: }
|