| 1 2 60 package org.objectstyle.cayenne.exp.parser; 61 import java.io.*; 62 import java.util.*; 63 import java.math.*; 64 import org.objectstyle.cayenne.exp.*; 65 66 public class ExpressionParserTokenManager implements ExpressionParserConstants 67 { 68 69 Object literalValue; 70 71 72 private StringBuffer stringBuffer; 73 74 75 private char escapeChar() 76 { 77 int ofs = image.length() - 1; 78 switch ( image.charAt(ofs) ) { 79 case 'n': return '\n'; 80 case 'r': return '\r'; 81 case 't': return '\t'; 82 case 'b': return '\b'; 83 case 'f': return '\f'; 84 case '\\': return '\\'; 85 case '\'': return '\''; 86 case '\"': return '\"'; 87 } 88 89 while ( image.charAt(--ofs) != '\\' ) 91 {} 92 int value = 0; 93 while ( ++ofs < image.length() ) 94 value = (value << 3) | (image.charAt(ofs) - '0'); 95 return (char) value; 96 } 97 98 private Object makeInt() 99 { 100 Object result; 101 String s = image.toString(); 102 int base = 10; 103 104 if ( s.charAt(0) == '0' ) 105 base = (s.length() > 1 && (s.charAt(1) == 'x' || s.charAt(1) == 'X'))? 16 : 8; 106 if ( base == 16 ) 107 s = s.substring(2); switch ( s.charAt(s.length()-1) ) { 109 case 'l': case 'L': 110 result = Long.valueOf( s.substring(0,s.length()-1), base ); 111 break; 112 113 case 'h': case 'H': 114 result = new BigInteger( s.substring(0,s.length()-1), base ); 115 break; 116 117 default: 118 result = Integer.valueOf( s, base ); 119 break; 120 } 121 return result; 122 } 123 124 private Object makeFloat() 125 { 126 String s = image.toString(); 127 switch ( s.charAt(s.length()-1) ) { 128 case 'f': case 'F': 129 return Float.valueOf( s ); 130 131 case 'b': case 'B': 132 return new BigDecimal( s.substring(0,s.length()-1) ); 133 134 case 'd': case 'D': 135 default: 136 return Double.valueOf( s ); 137 } 138 } 139 public java.io.PrintStream debugStream = System.out; 140 public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } 141 private final int jjStopStringLiteralDfa_0(int pos, long active0) 142 { 143 switch (pos) 144 { 145 case 0: 146 if ((active0 & 0x604e006L) != 0L) 147 { 148 jjmatchedKind = 32; 149 return 36; 150 } 151 if ((active0 & 0x8L) != 0L) 152 { 153 jjmatchedKind = 32; 154 return 2; 155 } 156 return -1; 157 case 1: 158 if ((active0 & 0x8002L) != 0L) 159 return 36; 160 if ((active0 & 0x604600cL) != 0L) 161 { 162 jjmatchedKind = 32; 163 jjmatchedPos = 1; 164 return 36; 165 } 166 return -1; 167 case 2: 168 if ((active0 & 0xcL) != 0L) 169 return 36; 170 if ((active0 & 0x2046000L) != 0L) 171 { 172 jjmatchedKind = 32; 173 jjmatchedPos = 2; 174 return 36; 175 } 176 return -1; 177 case 3: 178 if ((active0 & 0x6000L) != 0L) 179 return 36; 180 if ((active0 & 0x40000L) != 0L) 181 { 182 if (jjmatchedPos != 3) 183 { 184 jjmatchedKind = 32; 185 jjmatchedPos = 3; 186 } 187 return 36; 188 } 189 return -1; 190 case 4: 191 if ((active0 & 0x44000L) != 0L) 192 { 193 jjmatchedKind = 32; 194 jjmatchedPos = 4; 195 return 36; 196 } 197 return -1; 198 case 5: 199 if ((active0 & 0x44000L) != 0L) 200 { 201 jjmatchedKind = 32; 202 jjmatchedPos = 5; 203 return 36; 204 } 205 return -1; 206 case 6: 207 if ((active0 & 0x40000L) != 0L) 208 return 36; 209 if ((active0 & 0x4000L) != 0L) 210 { 211 jjmatchedKind = 32; 212 jjmatchedPos = 6; 213 return 36; 214 } 215 return -1; 216 case 7: 217 if ((active0 & 0x4000L) != 0L) 218 { 219 jjmatchedKind = 32; 220 jjmatchedPos = 7; 221 return 36; 222 } 223 return -1; 224 case 8: 225 if ((active0 & 0x4000L) != 0L) 226 { 227 jjmatchedKind = 32; 228 jjmatchedPos = 8; 229 return 36; 230 } 231 return -1; 232 case 9: 233 if ((active0 & 0x4000L) != 0L) 234 { 235 jjmatchedKind = 32; 236 jjmatchedPos = 9; 237 return 36; 238 } 239 return -1; 240 case 10: 241 if ((active0 & 0x4000L) != 0L) 242 { 243 jjmatchedKind = 32; 244 jjmatchedPos = 10; 245 return 36; 246 } 247 return -1; 248 case 11: 249 if ((active0 & 0x4000L) != 0L) 250 { 251 jjmatchedKind = 32; 252 jjmatchedPos = 11; 253 return 36; 254 } 255 return -1; 256 case 12: 257 if ((active0 & 0x4000L) != 0L) 258 { 259 jjmatchedKind = 32; 260 jjmatchedPos = 12; 261 return 36; 262 } 263 return -1; 264 default : 265 return -1; 266 } 267 } 268 private final int jjStartNfa_0(int pos, long active0) 269 { 270 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); 271 } 272 private final int jjStopAtPos(int pos, int kind) 273 { 274 jjmatchedKind = kind; 275 jjmatchedPos = pos; 276 return pos + 1; 277 } 278 private final int jjStartNfaWithStates_0(int pos, int kind, int state) 279 { 280 jjmatchedKind = kind; 281 jjmatchedPos = pos; 282 try { curChar = input_stream.readChar(); } 283 catch(java.io.IOException e) { return pos + 1; } 284 return jjMoveNfa_0(state, pos + 1); 285 } 286 private final int jjMoveStringLiteralDfa0_0() 287 { 288 switch(curChar) 289 { 290 case 33: 291 jjmatchedKind = 4; 292 return jjMoveStringLiteralDfa1_0(0x80L); 293 case 34: 294 return jjStopAtPos(0, 37); 295 case 36: 296 return jjStopAtPos(0, 24); 297 case 39: 298 return jjStopAtPos(0, 36); 299 case 40: 300 return jjStopAtPos(0, 16); 301 case 41: 302 return jjStopAtPos(0, 17); 303 case 42: 304 return jjStopAtPos(0, 22); 305 case 43: 306 return jjStopAtPos(0, 20); 307 case 44: 308 return jjStopAtPos(0, 19); 309 case 45: 310 return jjStopAtPos(0, 21); 311 case 47: 312 return jjStopAtPos(0, 23); 313 case 60: 314 jjmatchedKind = 10; 315 return jjMoveStringLiteralDfa1_0(0x300L); 316 case 61: 317 jjmatchedKind = 5; 318 return jjMoveStringLiteralDfa1_0(0x40L); 319 case 62: 320 jjmatchedKind = 11; 321 return jjMoveStringLiteralDfa1_0(0x1000L); 322 case 97: 323 return jjMoveStringLiteralDfa1_0(0x4L); 324 case 98: 325 return jjMoveStringLiteralDfa1_0(0x40000L); 326 case 100: 327 return jjMoveStringLiteralDfa1_0(0x4000000L); 328 case 105: 329 return jjMoveStringLiteralDfa1_0(0x8000L); 330 case 108: 331 return jjMoveStringLiteralDfa1_0(0x6000L); 332 case 110: 333 return jjMoveStringLiteralDfa1_0(0x8L); 334 case 111: 335 return jjMoveStringLiteralDfa1_0(0x2000002L); 336 default : 337 return jjMoveNfa_0(3, 0); 338 } 339 } 340 private final int jjMoveStringLiteralDfa1_0(long active0) 341 { 342 try { curChar = input_stream.readChar(); } 343 catch(java.io.IOException e) { 344 jjStopStringLiteralDfa_0(0, active0); 345 return 1; 346 } 347 switch(curChar) 348 { 349 case 61: 350 if ((active0 & 0x40L) != 0L) 351 return jjStopAtPos(1, 6); 352 else if ((active0 & 0x80L) != 0L) 353 return jjStopAtPos(1, 7); 354 else if ((active0 & 0x200L) != 0L) 355 return jjStopAtPos(1, 9); 356 else if ((active0 & 0x1000L) != 0L) 357 return jjStopAtPos(1, 12); 358 break; 359 case 62: 360 if ((active0 & 0x100L) != 0L) 361 return jjStopAtPos(1, 8); 362 break; 363 case 98: 364 return jjMoveStringLiteralDfa2_0(active0, 0x6000000L); 365 case 101: 366 return jjMoveStringLiteralDfa2_0(active0, 0x40000L); 367 case 105: 368 return jjMoveStringLiteralDfa2_0(active0, 0x6000L); 369 case 110: 370 if ((active0 & 0x8000L) != 0L) 371 return jjStartNfaWithStates_0(1, 15, 36); 372 return jjMoveStringLiteralDfa2_0(active0, 0x4L); 373 case 111: 374 return jjMoveStringLiteralDfa2_0(active0, 0x8L); 375 case 114: 376 if ((active0 & 0x2L) != 0L) 377 return jjStartNfaWithStates_0(1, 1, 36); 378 break; 379 default : 380 break; 381 } 382 return jjStartNfa_0(0, active0); 383 } 384 private final int jjMoveStringLiteralDfa2_0(long old0, long active0) 385 { 386 if (((active0 &= old0)) == 0L) 387 return jjStartNfa_0(0, old0); 388 try { curChar = input_stream.readChar(); } 389 catch(java.io.IOException e) { 390 jjStopStringLiteralDfa_0(1, active0); 391 return 2; 392 } 393 switch(curChar) 394 { 395 case 58: 396 if ((active0 & 0x4000000L) != 0L) 397 return jjStopAtPos(2, 26); 398 break; 399 case 100: 400 if ((active0 & 0x4L) != 0L) 401 return jjStartNfaWithStates_0(2, 2, 36); 402 break; 403 case 106: 404 return jjMoveStringLiteralDfa3_0(active0, 0x2000000L); 405 case 107: 406 return jjMoveStringLiteralDfa3_0(active0, 0x6000L); 407 case 116: 408 if ((active0 & 0x8L) != 0L) 409 return jjStartNfaWithStates_0(2, 3, 36); 410 return jjMoveStringLiteralDfa3_0(active0, 0x40000L); 411 default : 412 break; 413 } 414 return jjStartNfa_0(1, active0); 415 } 416 private final int jjMoveStringLiteralDfa3_0(long old0, long active0) 417 { 418 if (((active0 &= old0)) == 0L) 419 return jjStartNfa_0(1, old0); 420 try { curChar = input_stream.readChar(); } 421 catch(java.io.IOException e) { 422 jjStopStringLiteralDfa_0(2, active0); 423 return 3; 424 } 425 switch(curChar) 426 { 427 case 58: 428 if ((active0 & 0x2000000L) != 0L) 429 return jjStopAtPos(3, 25); 430 break; 431 case 101: 432 if ((active0 & 0x2000L) != 0L) 433 { 434 jjmatchedKind = 13; 435 jjmatchedPos = 3; 436 } 437 return jjMoveStringLiteralDfa4_0(active0, 0x4000L); 438 case 119: 439 return jjMoveStringLiteralDfa4_0(active0, 0x40000L); 440 default : 441 break; 442 } 443 return jjStartNfa_0(2, active0); 444 } 445 private final int jjMoveStringLiteralDfa4_0(long old0, long active0) 446 { 447 if (((active0 &= old0)) == 0L) 448 return jjStartNfa_0(2, old0); 449 try { curChar = input_stream.readChar(); } 450 catch(java.io.IOException e) { 451 jjStopStringLiteralDfa_0(3, active0); 452 return 4; 453 } 454 switch(curChar) 455 { 456 case 73: 457 return jjMoveStringLiteralDfa5_0(active0, 0x4000L); 458 case 101: 459 return jjMoveStringLiteralDfa5_0(active0, 0x40000L); 460 default : 461 break; 462 } 463 return jjStartNfa_0(3, active0); 464 } 465 private final int jjMoveStringLiteralDfa5_0(long old0, long active0) 466 { 467 if (((active0 &= old0)) == 0L) 468 return jjStartNfa_0(3, old0); 469 try { curChar = input_stream.readChar(); } 470 catch(java.io.IOException e) { 471 jjStopStringLiteralDfa_0(4, active0); 472 return 5; 473 } 474 switch(curChar) 475 { 476 case 101: 477 return jjMoveStringLiteralDfa6_0(active0, 0x40000L); 478 case 103: 479 return jjMoveStringLiteralDfa6_0(active0, 0x4000L); 480 default : 481 break; 482 } 483 return jjStartNfa_0(4, active0); 484 } 485 private final int jjMoveStringLiteralDfa6_0(long old0, long active0) 486 { 487 if (((active0 &= old0)) == 0L) 488 return jjStartNfa_0(4, old0); 489 try { curChar = input_stream.readChar(); } 490 catch(java.io.IOException e) { 491 jjStopStringLiteralDfa_0(5, active0); 492 return 6; 493 } 494 switch(curChar) 495 { 496 case 110: 497 if ((active0 & 0x40000L) != 0L) 498 return jjStartNfaWithStates_0(6, 18, 36); 499 return jjMoveStringLiteralDfa7_0(active0, 0x4000L); 500 default : 501 break; 502 } 503 return jjStartNfa_0(5, active0); 504 } 505 private final int jjMoveStringLiteralDfa7_0(long old0, long active0) 506 { 507 if (((active0 &= old0)) == 0L) 508 return jjStartNfa_0(5, old0); 509 try { curChar = input_stream.readChar(); } 510 catch(java.io.IOException e) { 511 jjStopStringLiteralDfa_0(6, active0); 512 return 7; 513 } 514 switch(curChar) 515 { 516 case 111: 517 return jjMoveStringLiteralDfa8_0(active0, 0x4000L); 518 default : 519 break; 520 } 521 return jjStartNfa_0(6, active0); 522 } 523 private final int jjMoveStringLiteralDfa8_0(long old0, long active0) 524 { 525 if (((active0 &= old0)) == 0L) 526 return jjStartNfa_0(6, old0); 527 try { curChar = input_stream.readChar(); } 528 catch(java.io.IOException e) { 529 jjStopStringLiteralDfa_0(7, active0); 530 return 8; 531 } 532 switch(curChar) 533 { 534 case 114: 535 return jjMoveStringLiteralDfa9_0(active0, 0x4000L); 536 default : 537 break; 538 } 539 return jjStartNfa_0(7, active0); 540 } 541 private final int jjMoveStringLiteralDfa9_0(long old0, long active0) 542 { 543 if (((active0 &= old0)) == 0L) 544 return jjStartNfa_0(7, old0); 545 try { curChar = input_stream.readChar(); } 546 catch(java.io.IOException e) { 547 jjStopStringLiteralDfa_0(8, active0); 548 return 9; 549 } 550 switch(curChar) 551 { 552 case 101: 553 return jjMoveStringLiteralDfa10_0(active0, 0x4000L); 554 default : 555 break; 556 } 557 return jjStartNfa_0(8, active0); 558 } 559 private final int jjMoveStringLiteralDfa10_0(long old0, long active0) 560 { 561 if (((active0 &= old0)) == 0L) 562 return jjStartNfa_0(8, old0); 563 try { curChar = input_stream.readChar(); } 564 catch(java.io.IOException e) { 565 jjStopStringLiteralDfa_0(9, active0); 566 return 10; 567 } 568 switch(curChar) 569 { 570 case 67: 571 return jjMoveStringLiteralDfa11_0(active0, 0x4000L); 572 default : 573 break; 574 } 575 return jjStartNfa_0(9, active0); 576 } 577 private final int jjMoveStringLiteralDfa11_0(long old0, long active0) 578 { 579 if (((active0 &= old0)) == 0L) 580 return jjStartNfa_0(9, old0); 581 try { curChar = input_stream.readChar(); } 582 catch(java.io.IOException e) { 583 jjStopStringLiteralDfa_0(10, active0); 584 return 11; 585 } 586 switch(curChar) 587 { 588 case 97: 589 return jjMoveStringLiteralDfa12_0(active0, 0x4000L); 590 default : 591 break; 592 } 593 return jjStartNfa_0(10, active0); 594 } 595 private final int jjMoveStringLiteralDfa12_0(long old0, long active0) 596 { 597 if (((active0 &= old0)) == 0L) 598 return jjStartNfa_0(10, old0); 599 try { curChar = input_stream.readChar(); } 600 catch(java.io.IOException e) { 601 jjStopStringLiteralDfa_0(11, active0); 602 return 12; 603 } 604 switch(curChar) 605 { 606 case 115: 607 return jjMoveStringLiteralDfa13_0(active0, 0x4000L); 608 default : 609 break; 610 } 611 return jjStartNfa_0(11, active0); 612 } 613 private final int jjMoveStringLiteralDfa13_0(long old0, long active0) 614 { 615 if (((active0 &= old0)) == 0L) 616 return jjStartNfa_0(11, old0); 617 try { curChar = input_stream.readChar(); } 618 catch(java.io.IOException e) { 619 jjStopStringLiteralDfa_0(12, active0); 620 return 13; 621 } 622 switch(curChar) 623 { 624 case 101: 625 if ((active0 & 0x4000L) != 0L) 626 return jjStartNfaWithStates_0(13, 14, 36); 627 break; 628 default : 629 break; 630 } 631 return jjStartNfa_0(12, active0); 632 } 633 private final void jjCheckNAdd(int state) 634 { 635 if (jjrounds[state] != jjround) 636 { 637 jjstateSet[jjnewStateCnt++] = state; 638 jjrounds[state] = jjround; 639 } 640 } 641 private final void jjAddStates(int start, int end) 642 { 643 do { 644 jjstateSet[jjnewStateCnt++] = jjnextStates[start]; 645 } while (start++ != end); 646 } 647 private final void jjCheckNAddTwoStates(int state1, int state2) 648 { 649 jjCheckNAdd(state1); 650 jjCheckNAdd(state2); 651 } 652 private final void jjCheckNAddStates(int start, int end) 653 { 654 do { 655 jjCheckNAdd(jjnextStates[start]); 656 } while (start++ != end); 657 } 658 private final void jjCheckNAddStates(int start) 659 { 660 jjCheckNAdd(jjnextStates[start]); 661 jjCheckNAdd(jjnextStates[start + 1]); 662 } 663 private final int jjMoveNfa_0(int startState, int curPos) 664 { 665 int[] nextStates; 666 int startsAt = 0; 667 jjnewStateCnt = 36; 668 int i = 1; 669 jjstateSet[0] = startState; 670 int j, kind = 0x7fffffff; 671 for (;;) 672 { 673 if (++jjround == 0x7fffffff) 674 ReInitRounds(); 675 if (curChar < 64) 676 { 677 long l = 1L << curChar; 678 MatchLoop: do 679 { 680 switch(jjstateSet[--i]) 681 { 682 case 3: 683 if ((0x3ff000000000000L & l) != 0L) 684 jjCheckNAddStates(0, 5); 685 else if (curChar == 46) 686 jjCheckNAdd(12); 687 if ((0x3fe000000000000L & l) != 0L) 688 { 689 if (kind > 44) 690 kind = 44; 691 jjCheckNAddTwoStates(9, 10); 692 } 693 else if (curChar == 48) 694 { 695 if (kind > 44) 696 kind = 44; 697 jjCheckNAddStates(6, 8); 698 } 699 break; 700 case 36: 701 if ((0x3ff000000000000L & l) != 0L) 702 { 703 if (kind > 33) 704 kind = 33; 705 jjCheckNAdd(35); 706 } 707 else if (curChar == 46) 708 jjstateSet[jjnewStateCnt++] = 33; 709 if ((0x3ff000000000000L & l) != 0L) 710 { 711 if (kind > 32) 712 kind = 32; 713 jjCheckNAddTwoStates(31, 32); 714 } 715 break; 716 case 2: 717 if ((0x3ff000000000000L & l) != 0L) 718 { 719 if (kind > 33) 720 kind = 33; 721 jjCheckNAdd(35); 722 } 723 else if (curChar == 46) 724 jjstateSet[jjnewStateCnt++] = 33; 725 if ((0x3ff000000000000L & l) != 0L) 726 { 727 if (kind > 32) 728 kind = 32; 729 jjCheckNAddTwoStates(31, 32); 730 } 731 break; 732 case 8: 733 if ((0x3fe000000000000L & l) == 0L) 734 break; 735 if (kind > 44) 736 kind = 44; 737 jjCheckNAddTwoStates(9, 10); 738 break; 739 case 9: 740 if ((0x3ff000000000000L & l) == 0L) 741 break; 742 if (kind > 44) 743 kind = 44; 744 jjCheckNAddTwoStates(9, 10); 745 break; 746 case 11: 747 if (curChar == 46) 748 jjCheckNAdd(12); 749 break; 750 case 12: 751 if ((0x3ff000000000000L & l) == 0L) 752 break; 753 if (kind > 45) 754 kind = 45; 755 jjCheckNAddStates(9, 11); 756 break; 757 case 14: 758 if ((0x280000000000L & l) != 0L) 759 jjCheckNAdd(15); 760 break; 761 case 15: 762 if ((0x3ff000000000000L & l) == 0L) 763 break; 764 if (kind > 45) 765 kind = 45; 766 jjCheckNAddTwoStates(15, 16); 767 break; 768 case 17: 769 if ((0x3ff000000000000L & l) != 0L) 770 jjCheckNAddStates(0, 5); 771 break; 772 case 18: 773 if ((0x3ff000000000000L & l) != 0L) 774 jjCheckNAddTwoStates(18, 19); 775 break; 776 case 19: 777 if (curChar != 46) 778 break; 779 if (kind > 45) 780 kind = 45; 781 jjCheckNAddStates(12, 14); 782 break; 783 case 20: 784 if ((0x3ff000000000000L & l) == 0L) 785 break; 786 if (kind > 45) 787 kind = 45; 788 jjCheckNAddStates(12, 14); 789 break; 790 case 21: 791 if ((0x3ff000000000000L & l) != 0L) 792 jjCheckNAddTwoStates(21, 22); 793 break; 794 case 23: 795 if ((0x280000000000L & l) != 0L) 796 jjCheckNAdd(24); 797 break; 798 case 24: 799 if ((0x3ff000000000000L & l) == 0L) 800 &nbs
|