001 /* Generated By:JavaCC: Do not edit this line. PropertyListParserTokenManager.java */
002 package org.apache.commons.configuration.plist;
003 import java.util.Date;
004 import java.util.List;
005 import java.util.ArrayList;
006 import org.apache.commons.configuration.HierarchicalConfiguration;
007 import org.apache.commons.configuration.HierarchicalConfiguration.Node;
008 import org.apache.commons.codec.binary.Hex;
009
010 /** Token Manager. */
011 public class PropertyListParserTokenManager implements PropertyListParserConstants
012 {
013
014 /** Debug output. */
015 public java.io.PrintStream debugStream = System.out;
016 /** Set debug output. */
017 public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
018 private final int jjStopStringLiteralDfa_0(int pos, long active0)
019 {
020 switch (pos)
021 {
022 case 0:
023 if ((active0 & 0x2000L) != 0L)
024 return 8;
025 if ((active0 & 0x8000L) != 0L)
026 return 14;
027 if ((active0 & 0x800000L) != 0L)
028 {
029 jjmatchedKind = 21;
030 return 8;
031 }
032 if ((active0 & 0x5000L) != 0L)
033 return 6;
034 return -1;
035 case 1:
036 if ((active0 & 0x4000L) != 0L)
037 {
038 jjmatchedKind = 21;
039 jjmatchedPos = 1;
040 return 3;
041 }
042 return -1;
043 default :
044 return -1;
045 }
046 }
047 private final int jjStartNfa_0(int pos, long active0)
048 {
049 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
050 }
051 private int jjStopAtPos(int pos, int kind)
052 {
053 jjmatchedKind = kind;
054 jjmatchedPos = pos;
055 return pos + 1;
056 }
057 private int jjMoveStringLiteralDfa0_0()
058 {
059 switch(curChar)
060 {
061 case 34:
062 return jjStartNfaWithStates_0(0, 15, 14);
063 case 40:
064 return jjStopAtPos(0, 5);
065 case 41:
066 return jjStopAtPos(0, 6);
067 case 44:
068 return jjStopAtPos(0, 7);
069 case 59:
070 return jjStopAtPos(0, 10);
071 case 60:
072 jjmatchedKind = 12;
073 return jjMoveStringLiteralDfa1_0(0x4000L);
074 case 61:
075 return jjStopAtPos(0, 11);
076 case 62:
077 return jjStartNfaWithStates_0(0, 13, 8);
078 case 92:
079 return jjMoveStringLiteralDfa1_0(0x800000L);
080 case 123:
081 return jjStopAtPos(0, 8);
082 case 125:
083 return jjStopAtPos(0, 9);
084 default :
085 return jjMoveNfa_0(0, 0);
086 }
087 }
088 private int jjMoveStringLiteralDfa1_0(long active0)
089 {
090 try { curChar = input_stream.readChar(); }
091 catch(java.io.IOException e) {
092 jjStopStringLiteralDfa_0(0, active0);
093 return 1;
094 }
095 switch(curChar)
096 {
097 case 34:
098 if ((active0 & 0x800000L) != 0L)
099 return jjStopAtPos(1, 23);
100 break;
101 case 42:
102 return jjMoveStringLiteralDfa2_0(active0, 0x4000L);
103 default :
104 break;
105 }
106 return jjStartNfa_0(0, active0);
107 }
108 private 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 68:
120 if ((active0 & 0x4000L) != 0L)
121 return jjStartNfaWithStates_0(2, 14, 15);
122 break;
123 default :
124 break;
125 }
126 return jjStartNfa_0(1, active0);
127 }
128 private int jjStartNfaWithStates_0(int pos, int kind, int state)
129 {
130 jjmatchedKind = kind;
131 jjmatchedPos = pos;
132 try { curChar = input_stream.readChar(); }
133 catch(java.io.IOException e) { return pos + 1; }
134 return jjMoveNfa_0(state, pos + 1);
135 }
136 static final long[] jjbitVec0 = {
137 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
138 };
139 private int jjMoveNfa_0(int startState, int curPos)
140 {
141 int startsAt = 0;
142 jjnewStateCnt = 14;
143 int i = 1;
144 jjstateSet[0] = startState;
145 int kind = 0x7fffffff;
146 for (;;)
147 {
148 if (++jjround == 0x7fffffff)
149 ReInitRounds();
150 if (curChar < 64)
151 {
152 long l = 1L << curChar;
153 do
154 {
155 switch(jjstateSet[--i])
156 {
157 case 15:
158 if ((0xd7ffecfaffffd9ffL & l) != 0L)
159 {
160 if (kind > 21)
161 kind = 21;
162 jjCheckNAdd(8);
163 }
164 if ((0x7ff280100000000L & l) != 0L)
165 jjCheckNAddTwoStates(4, 5);
166 else if (curChar == 62)
167 {
168 if (kind > 20)
169 kind = 20;
170 }
171 break;
172 case 6:
173 if ((0xd7ffecfaffffd9ffL & l) != 0L)
174 {
175 if (kind > 21)
176 kind = 21;
177 jjCheckNAdd(8);
178 }
179 if ((0x3ff000100002600L & l) != 0L)
180 jjCheckNAddTwoStates(1, 2);
181 else if (curChar == 42)
182 jjstateSet[jjnewStateCnt++] = 3;
183 else if (curChar == 62)
184 {
185 if (kind > 19)
186 kind = 19;
187 }
188 break;
189 case 14:
190 if ((0xfffffffbffffffffL & l) != 0L)
191 jjCheckNAddStates(0, 2);
192 else if (curChar == 34)
193 {
194 if (kind > 22)
195 kind = 22;
196 }
197 break;
198 case 3:
199 case 8:
200 if ((0xd7ffecfaffffd9ffL & l) == 0L)
201 break;
202 if (kind > 21)
203 kind = 21;
204 jjCheckNAdd(8);
205 break;
206 case 0:
207 if ((0xd7ffecfaffffd9ffL & l) != 0L)
208 {
209 if (kind > 21)
210 kind = 21;
211 jjCheckNAdd(8);
212 }
213 else if (curChar == 34)
214 jjCheckNAddStates(0, 2);
215 if (curChar == 60)
216 jjstateSet[jjnewStateCnt++] = 6;
217 if (curChar == 60)
218 jjCheckNAddTwoStates(1, 2);
219 break;
220 case 1:
221 if ((0x3ff000100002600L & l) != 0L)
222 jjCheckNAddTwoStates(1, 2);
223 break;
224 case 2:
225 if (curChar == 62 && kind > 19)
226 kind = 19;
227 break;
228 case 4:
229 if ((0x7ff280100000000L & l) != 0L)
230 jjCheckNAddTwoStates(4, 5);
231 break;
232 case 5:
233 if (curChar == 62 && kind > 20)
234 kind = 20;
235 break;
236 case 7:
237 if (curChar == 60)
238 jjstateSet[jjnewStateCnt++] = 6;
239 break;
240 case 9:
241 case 11:
242 if (curChar == 34)
243 jjCheckNAddStates(0, 2);
244 break;
245 case 10:
246 if ((0xfffffffbffffffffL & l) != 0L)
247 jjCheckNAddStates(0, 2);
248 break;
249 case 13:
250 if (curChar == 34 && kind > 22)
251 kind = 22;
252 break;
253 default : break;
254 }
255 } while(i != startsAt);
256 }
257 else if (curChar < 128)
258 {
259 long l = 1L << (curChar & 077);
260 do
261 {
262 switch(jjstateSet[--i])
263 {
264 case 15:
265 if ((0xd7ffffffffffffffL & l) != 0L)
266 {
267 if (kind > 21)
268 kind = 21;
269 jjCheckNAdd(8);
270 }
271 if (curChar == 90)
272 jjCheckNAddTwoStates(4, 5);
273 break;
274 case 6:
275 if ((0xd7ffffffffffffffL & l) != 0L)
276 {
277 if (kind > 21)
278 kind = 21;
279 jjCheckNAdd(8);
280 }
281 if ((0x7e0000007eL & l) != 0L)
282 jjCheckNAddTwoStates(1, 2);
283 break;
284 case 14:
285 jjCheckNAddStates(0, 2);
286 if (curChar == 92)
287 jjstateSet[jjnewStateCnt++] = 11;
288 break;
289 case 3:
290 if ((0xd7ffffffffffffffL & l) != 0L)
291 {
292 if (kind > 21)
293 kind = 21;
294 jjCheckNAdd(8);
295 }
296 if (curChar == 68)
297 jjCheckNAddTwoStates(4, 5);
298 break;
299 case 0:
300 case 8:
301 if ((0xd7ffffffffffffffL & l) == 0L)
302 break;
303 if (kind > 21)
304 kind = 21;
305 jjCheckNAdd(8);
306 break;
307 case 1:
308 if ((0x7e0000007eL & l) != 0L)
309 jjCheckNAddTwoStates(1, 2);
310 break;
311 case 4:
312 if (curChar == 90)
313 jjCheckNAddTwoStates(4, 5);
314 break;
315 case 10:
316 jjCheckNAddStates(0, 2);
317 break;
318 case 12:
319 if (curChar == 92)
320 jjstateSet[jjnewStateCnt++] = 11;
321 break;
322 default : break;
323 }
324 } while(i != startsAt);
325 }
326 else
327 {
328 int i2 = (curChar & 0xff) >> 6;
329 long l2 = 1L << (curChar & 077);
330 do
331 {
332 switch(jjstateSet[--i])
333 {
334 case 15:
335 case 8:
336 if ((jjbitVec0[i2] & l2) == 0L)
337 break;
338 if (kind > 21)
339 kind = 21;
340 jjCheckNAdd(8);
341 break;
342 case 6:
343 if ((jjbitVec0[i2] & l2) == 0L)
344 break;
345 if (kind > 21)
346 kind = 21;
347 jjCheckNAdd(8);
348 break;
349 case 14:
350 case 10:
351 if ((jjbitVec0[i2] & l2) != 0L)
352 jjCheckNAddStates(0, 2);
353 break;
354 case 3:
355 if ((jjbitVec0[i2] & l2) == 0L)
356 break;
357 if (kind > 21)
358 kind = 21;
359 jjCheckNAdd(8);
360 break;
361 case 0:
362 if ((jjbitVec0[i2] & l2) == 0L)
363 break;
364 if (kind > 21)
365 kind = 21;
366 jjCheckNAdd(8);
367 break;
368 default : break;
369 }
370 } while(i != startsAt);
371 }
372 if (kind != 0x7fffffff)
373 {
374 jjmatchedKind = kind;
375 jjmatchedPos = curPos;
376 kind = 0x7fffffff;
377 }
378 ++curPos;
379 if ((i = jjnewStateCnt) == (startsAt = 14 - (jjnewStateCnt = startsAt)))
380 return curPos;
381 try { curChar = input_stream.readChar(); }
382 catch(java.io.IOException e) { return curPos; }
383 }
384 }
385 static final int[] jjnextStates = {
386 10, 12, 13,
387 };
388
389 /** Token literal values. */
390 public static final String[] jjstrLiteralImages = {
391 "", null, null, null, null, "\50", "\51", "\54", "\173", "\175", "\73", "\75",
392 "\74", "\76", "\74\52\104", "\42", null, null, null, null, null, null, null,
393 "\134\42", };
394
395 /** Lexer state names. */
396 public static final String[] lexStateNames = {
397 "DEFAULT",
398 };
399 static final long[] jjtoToken = {
400 0xf8ffe1L,
401 };
402 static final long[] jjtoSkip = {
403 0x1eL,
404 };
405 protected SimpleCharStream input_stream;
406 private final int[] jjrounds = new int[14];
407 private final int[] jjstateSet = new int[28];
408 protected char curChar;
409 /** Constructor. */
410 public PropertyListParserTokenManager(SimpleCharStream stream){
411 if (SimpleCharStream.staticFlag)
412 throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
413 input_stream = stream;
414 }
415
416 /** Constructor. */
417 public PropertyListParserTokenManager(SimpleCharStream stream, int lexState){
418 this(stream);
419 SwitchTo(lexState);
420 }
421
422 /** Reinitialise parser. */
423 public void ReInit(SimpleCharStream stream)
424 {
425 jjmatchedPos = jjnewStateCnt = 0;
426 curLexState = defaultLexState;
427 input_stream = stream;
428 ReInitRounds();
429 }
430 private void ReInitRounds()
431 {
432 int i;
433 jjround = 0x80000001;
434 for (i = 14; i-- > 0;)
435 jjrounds[i] = 0x80000000;
436 }
437
438 /** Reinitialise parser. */
439 public void ReInit(SimpleCharStream stream, int lexState)
440 {
441 ReInit(stream);
442 SwitchTo(lexState);
443 }
444
445 /** Switch to specified lex state. */
446 public void SwitchTo(int lexState)
447 {
448 if (lexState >= 1 || lexState < 0)
449 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
450 else
451 curLexState = lexState;
452 }
453
454 protected Token jjFillToken()
455 {
456 final Token t;
457 final String curTokenImage;
458 final int beginLine;
459 final int endLine;
460 final int beginColumn;
461 final int endColumn;
462 String im = jjstrLiteralImages[jjmatchedKind];
463 curTokenImage = (im == null) ? input_stream.GetImage() : im;
464 beginLine = input_stream.getBeginLine();
465 beginColumn = input_stream.getBeginColumn();
466 endLine = input_stream.getEndLine();
467 endColumn = input_stream.getEndColumn();
468 t = Token.newToken(jjmatchedKind, curTokenImage);
469
470 t.beginLine = beginLine;
471 t.endLine = endLine;
472 t.beginColumn = beginColumn;
473 t.endColumn = endColumn;
474
475 return t;
476 }
477
478 int curLexState = 0;
479 int defaultLexState = 0;
480 int jjnewStateCnt;
481 int jjround;
482 int jjmatchedPos;
483 int jjmatchedKind;
484
485 /** Get the next Token. */
486 public Token getNextToken()
487 {
488 Token matchedToken;
489 int curPos = 0;
490
491 EOFLoop :
492 for (;;)
493 {
494 try
495 {
496 curChar = input_stream.BeginToken();
497 }
498 catch(java.io.IOException e)
499 {
500 jjmatchedKind = 0;
501 matchedToken = jjFillToken();
502 return matchedToken;
503 }
504
505 try { input_stream.backup(0);
506 while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
507 curChar = input_stream.BeginToken();
508 }
509 catch (java.io.IOException e1) { continue EOFLoop; }
510 jjmatchedKind = 0x7fffffff;
511 jjmatchedPos = 0;
512 curPos = jjMoveStringLiteralDfa0_0();
513 if (jjmatchedKind != 0x7fffffff)
514 {
515 if (jjmatchedPos + 1 < curPos)
516 input_stream.backup(curPos - jjmatchedPos - 1);
517 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
518 {
519 matchedToken = jjFillToken();
520 return matchedToken;
521 }
522 else
523 {
524 continue EOFLoop;
525 }
526 }
527 int error_line = input_stream.getEndLine();
528 int error_column = input_stream.getEndColumn();
529 String error_after = null;
530 boolean EOFSeen = false;
531 try { input_stream.readChar(); input_stream.backup(1); }
532 catch (java.io.IOException e1) {
533 EOFSeen = true;
534 error_after = curPos <= 1 ? "" : input_stream.GetImage();
535 if (curChar == '\n' || curChar == '\r') {
536 error_line++;
537 error_column = 0;
538 }
539 else
540 error_column++;
541 }
542 if (!EOFSeen) {
543 input_stream.backup(1);
544 error_after = curPos <= 1 ? "" : input_stream.GetImage();
545 }
546 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
547 }
548 }
549
550 private void jjCheckNAdd(int state)
551 {
552 if (jjrounds[state] != jjround)
553 {
554 jjstateSet[jjnewStateCnt++] = state;
555 jjrounds[state] = jjround;
556 }
557 }
558 private void jjAddStates(int start, int end)
559 {
560 do {
561 jjstateSet[jjnewStateCnt++] = jjnextStates[start];
562 } while (start++ != end);
563 }
564 private void jjCheckNAddTwoStates(int state1, int state2)
565 {
566 jjCheckNAdd(state1);
567 jjCheckNAdd(state2);
568 }
569
570 private void jjCheckNAddStates(int start, int end)
571 {
572 do {
573 jjCheckNAdd(jjnextStates[start]);
574 } while (start++ != end);
575 }
576
577 }