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