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