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