1 2 3 package org.sablecc.sablecc.syntax3.lexer; 4 5 import java.io.*; 6 import org.sablecc.sablecc.syntax3.node.*; 7 8 @SuppressWarnings ("nls") 9 public class Lexer 10 { 11 protected Token token; 12 protected State state = State.INITIAL; 13 14 private PushbackReader in; 15 private int line; 16 private int pos; 17 private boolean cr; 18 private boolean eof; 19 private final StringBuffer text = new StringBuffer (); 20 21 @SuppressWarnings ("unused") 22 protected void filter() throws LexerException, IOException 23 { 24 } 26 27 public Lexer(@SuppressWarnings ("hiding") PushbackReader in) 28 { 29 this.in = in; 30 } 31 32 public Token peek() throws LexerException, IOException 33 { 34 while(this.token == null) 35 { 36 this.token = getToken(); 37 filter(); 38 } 39 40 return this.token; 41 } 42 43 public Token next() throws LexerException, IOException 44 { 45 while(this.token == null) 46 { 47 this.token = getToken(); 48 filter(); 49 } 50 51 Token result = this.token; 52 this.token = null; 53 return result; 54 } 55 56 protected Token getToken() throws IOException, LexerException 57 { 58 int dfa_state = 0; 59 60 int start_pos = this.pos; 61 int start_line = this.line; 62 63 int accept_state = -1; 64 int accept_token = -1; 65 int accept_length = -1; 66 int accept_pos = -1; 67 int accept_line = -1; 68 69 @SuppressWarnings ("hiding") int[][][] gotoTable = Lexer.gotoTable[this.state.id()]; 70 @SuppressWarnings ("hiding") int[] accept = Lexer.accept[this.state.id()]; 71 this.text.setLength(0); 72 73 while(true) 74 { 75 int c = getChar(); 76 77 if(c != -1) 78 { 79 switch(c) 80 { 81 case 10: 82 if(this.cr) 83 { 84 this.cr = false; 85 } 86 else 87 { 88 this.line++; 89 this.pos = 0; 90 } 91 break; 92 case 13: 93 this.line++; 94 this.pos = 0; 95 this.cr = true; 96 break; 97 default: 98 this.pos++; 99 this.cr = false; 100 break; 101 } 102 103 this.text.append((char) c); 104 105 do 106 { 107 int oldState = (dfa_state < -1) ? (-2 -dfa_state) : dfa_state; 108 109 dfa_state = -1; 110 111 int[][] tmp1 = gotoTable[oldState]; 112 int low = 0; 113 int high = tmp1.length - 1; 114 115 while(low <= high) 116 { 117 int middle = (low + high) / 2; 118 int[] tmp2 = tmp1[middle]; 119 120 if(c < tmp2[0]) 121 { 122 high = middle - 1; 123 } 124 else if(c > tmp2[1]) 125 { 126 low = middle + 1; 127 } 128 else 129 { 130 dfa_state = tmp2[2]; 131 break; 132 } 133 } 134 }while(dfa_state < -1); 135 } 136 else 137 { 138 dfa_state = -1; 139 } 140 141 if(dfa_state >= 0) 142 { 143 if(accept[dfa_state] != -1) 144 { 145 accept_state = dfa_state; 146 accept_token = accept[dfa_state]; 147 accept_length = this.text.length(); 148 accept_pos = this.pos; 149 accept_line = this.line; 150 } 151 } 152 else 153 { 154 if(accept_state != -1) 155 { 156 switch(accept_token) 157 { 158 case 0: 159 { 160 @SuppressWarnings ("hiding") Token token = new0( 161 start_line + 1, 162 start_pos + 1); 163 pushBack(accept_length); 164 this.pos = accept_pos; 165 this.line = accept_line; 166 return token; 167 } 168 case 1: 169 { 170 @SuppressWarnings ("hiding") Token token = new1( 171 start_line + 1, 172 start_pos + 1); 173 pushBack(accept_length); 174 this.pos = accept_pos; 175 this.line = accept_line; 176 return token; 177 } 178 case 2: 179 { 180 @SuppressWarnings ("hiding") Token token = new2( 181 start_line + 1, 182 start_pos + 1); 183 pushBack(accept_length); 184 this.pos = accept_pos; 185 this.line = accept_line; 186 return token; 187 } 188 case 3: 189 { 190 @SuppressWarnings ("hiding") Token token = new3( 191 start_line + 1, 192 start_pos + 1); 193 pushBack(accept_length); 194 this.pos = accept_pos; 195 this.line = accept_line; 196 return token; 197 } 198 case 4: 199 { 200 @SuppressWarnings ("hiding") Token token = new4( 201 start_line + 1, 202 start_pos + 1); 203 pushBack(accept_length); 204 this.pos = accept_pos; 205 this.line = accept_line; 206 return token; 207 } 208 case 5: 209 { 210 @SuppressWarnings ("hiding") Token token = new5( 211 start_line + 1, 212 start_pos + 1); 213 pushBack(accept_length); 214 this.pos = accept_pos; 215 this.line = accept_line; 216 return token; 217 } 218 case 6: 219 { 220 @SuppressWarnings ("hiding") Token token = new6( 221 start_line + 1, 222 start_pos + 1); 223 pushBack(accept_length); 224 this.pos = accept_pos; 225 this.line = accept_line; 226 return token; 227 } 228 case 7: 229 { 230 @SuppressWarnings ("hiding") Token token = new7( 231 start_line + 1, 232 start_pos + 1); 233 pushBack(accept_length); 234 this.pos = accept_pos; 235 this.line = accept_line; 236 return token; 237 } 238 case 8: 239 { 240 @SuppressWarnings ("hiding") Token token = new8( 241 start_line + 1, 242 start_pos + 1); 243 pushBack(accept_length); 244 this.pos = accept_pos; 245 this.line = accept_line; 246 return token; 247 } 248 case 9: 249 { 250 @SuppressWarnings ("hiding") Token token = new9( 251 start_line + 1, 252 start_pos + 1); 253 pushBack(accept_length); 254 this.pos = accept_pos; 255 this.line = accept_line; 256 return token; 257 } 258 case 10: 259 { 260 @SuppressWarnings ("hiding") Token token = new10( 261 start_line + 1, 262 start_pos + 1); 263 pushBack(accept_length); 264 this.pos = accept_pos; 265 this.line = accept_line; 266 return token; 267 } 268 case 11: 269 { 270 @SuppressWarnings ("hiding") Token token = new11( 271 start_line + 1, 272 start_pos + 1); 273 pushBack(accept_length); 274 this.pos = accept_pos; 275 this.line = accept_line; 276 return token; 277 } 278 case 12: 279 { 280 @SuppressWarnings ("hiding") Token token = new12( 281 start_line + 1, 282 start_pos + 1); 283 pushBack(accept_length); 284 this.pos = accept_pos; 285 this.line = accept_line; 286 return token; 287 } 288 case 13: 289 { 290 @SuppressWarnings ("hiding") Token token = new13( 291 start_line + 1, 292 start_pos + 1); 293 pushBack(accept_length); 294 this.pos = accept_pos; 295 this.line = accept_line; 296 return token; 297 } 298 case 14: 299 { 300 @SuppressWarnings ("hiding") Token token = new14( 301 start_line + 1, 302 start_pos + 1); 303 pushBack(accept_length); 304 this.pos = accept_pos; 305 this.line = accept_line; 306 return token; 307 } 308 case 15: 309 { 310 @SuppressWarnings ("hiding") Token token = new15( 311 start_line + 1, 312 start_pos + 1); 313 pushBack(accept_length); 314 this.pos = accept_pos; 315 this.line = accept_line; 316 return token; 317 } 318 case 16: 319 { 320 @SuppressWarnings ("hiding") Token token = new16( 321 start_line + 1, 322 start_pos + 1); 323 pushBack(accept_length); 324 this.pos = accept_pos; 325 this.line = accept_line; 326 return token; 327 } 328 case 17: 329 { 330 @SuppressWarnings ("hiding") Token token = new17( 331 start_line + 1, 332 start_pos + 1); 333 pushBack(accept_length); 334 this.pos = accept_pos; 335 this.line = accept_line; 336 return token; 337 } 338 case 18: 339 { 340 @SuppressWarnings ("hiding") Token token = new18( 341 start_line + 1, 342 start_pos + 1); 343 pushBack(accept_length); 344 this.pos = accept_pos; 345 this.line = accept_line; 346 return token; 347 } 348 case 19: 349 { 350 @SuppressWarnings ("hiding") Token token = new19( 351 start_line + 1, 352 start_pos + 1); 353 pushBack(accept_length); 354 this.pos = accept_pos; 355 this.line = accept_line; 356 return token; 357 } 358 case 20: 359 { 360 @SuppressWarnings ("hiding") Token token = new20( 361 start_line + 1, 362 start_pos + 1); 363 pushBack(accept_length); 364 this.pos = accept_pos; 365 this.line = accept_line; 366 return token; 367 } 368 case 21: 369 { 370 @SuppressWarnings ("hiding") Token token = new21( 371 start_line + 1, 372 start_pos + 1); 373 pushBack(accept_length); 374 this.pos = accept_pos; 375 this.line = accept_line; 376 return token; 377 } 378 case 22: 379 { 380 @SuppressWarnings ("hiding") Token token = new22( 381 start_line + 1, 382 start_pos + 1); 383 pushBack(accept_length); 384 this.pos = accept_pos; 385 this.line = accept_line; 386 return token; 387 } 388 case 23: 389 { 390 @SuppressWarnings ("hiding") Token token = new23( 391 start_line + 1, 392 start_pos + 1); 393 pushBack(accept_length); 394 this.pos = accept_pos; 395 this.line = accept_line; 396 return token; 397 } 398 case 24: 399 { 400 @SuppressWarnings ("hiding") Token token = new24( 401 start_line + 1, 402 start_pos + 1); 403 pushBack(accept_length); 404 this.pos = accept_pos; 405 this.line = accept_line; 406 return token; 407 } 408 case 25: 409 { 410 @SuppressWarnings ("hiding") Token token = new25( 411 start_line + 1, 412 start_pos + 1); 413 pushBack(accept_length); 414 this.pos = accept_pos; 415 this.line = accept_line; 416 return token; 417 } 418 case 26: 419 { 420 @SuppressWarnings ("hiding") Token token = new26( 421 start_line + 1, 422 start_pos + 1); 423 pushBack(accept_length); 424 this.pos = accept_pos; 425 this.line = accept_line; 426 return token; 427 } 428 case 27: 429 { 430 @SuppressWarnings ("hiding") Token token = new27( 431 start_line + 1, 432 start_pos + 1); 433 pushBack(accept_length); 434 this.pos = accept_pos; 435 this.line = accept_line; 436 return token; 437 } 438 case 28: 439 { 440 @SuppressWarnings ("hiding") Token token = new28( 441 start_line + 1, 442 start_pos + 1); 443 pushBack(accept_length); 444 this.pos = accept_pos; 445 this.line = accept_line; 446 return token; 447 } 448 case 29: 449 { 450 @SuppressWarnings ("hiding") Token token = new29( 451 start_line + 1, 452 start_pos + 1); 453 pushBack(accept_length); 454 this.pos = accept_pos; 455 this.line = accept_line; 456 return token; 457 } 458 case 30: 459 { 460 @SuppressWarnings ("hiding") Token token = new30( 461 start_line + 1, 462 start_pos + 1); 463 pushBack(accept_length); 464 this.pos = accept_pos; 465 this.line = accept_line; 466 return token; 467 } 468 case 31: 469 { 470 @SuppressWarnings ("hiding") Token token = new31( 471 start_line + 1, 472 start_pos + 1); 473 pushBack(accept_length); 474 this.pos = accept_pos; 475 this.line = accept_line; 476 return token; 477 } 478 case 32: 479 { 480 @SuppressWarnings ("hiding") Token token = new32( 481 start_line + 1, 482 start_pos + 1); 483 pushBack(accept_length); 484 this.pos = accept_pos; 485 this.line = accept_line; 486 return token; 487 } 488 case 33: 489 { 490 @SuppressWarnings ("hiding") Token token = new33( 491 start_line + 1, 492 start_pos + 1); 493 pushBack(accept_length); 494 this.pos = accept_pos; 495 this.line = accept_line; 496 return token; 497 } 498 case 34: 499 { 500 @SuppressWarnings ("hiding") Token token = new34( 501 start_line + 1, 502 start_pos + 1); 503 pushBack(accept_length); 504 this.pos = accept_pos; 505 this.line = accept_line; 506 return token; 507 } 508 case 35: 509 { 510 @SuppressWarnings ("hiding") Token token = new35( 511 start_line + 1, 512 start_pos + 1); 513 pushBack(accept_length); 514 this.pos = accept_pos; 515 this.line = accept_line; 516 return token; 517 } 518 case 36: 519 { 520 @SuppressWarnings ("hiding") Token token = new36( 521 start_line + 1, 522 start_pos + 1); 523 pushBack(accept_length); 524 this.pos = accept_pos; 525 this.line = accept_line; 526 return token; 527 } 528 case 37: 529 { 530 @SuppressWarnings ("hiding") Token token = new37( 531 start_line + 1, 532 start_pos + 1); 533 pushBack(accept_length); 534 this.pos = accept_pos; 535 this.line = accept_line; 536 return token; 537 } 538 case 38: 539 { 540 @SuppressWarnings ("hiding") Token token = new38( 541 getText(accept_length), 542 start_line + 1, 543 start_pos + 1); 544 pushBack(accept_length); 545 this.pos = accept_pos; 546 this.line = accept_line; 547 return token; 548 } 549 case 39: 550 { 551 @SuppressWarnings ("hiding") Token token = new39( 552 getText(accept_length), 553 start_line + 1, 554 start_pos + 1); 555 pushBack(accept_length); 556 this.pos = accept_pos; 557 this.line = accept_line; 558 return token; 559 } 560 case 40: 561 { 562 @SuppressWarnings ("hiding") Token token = new40( 563 getText(accept_length), 564 start_line + 1, 565 start_pos + 1); 566 pushBack(accept_length); 567 this.pos = accept_pos; 568 this.line = accept_line; 569 return token; 570 } 571 case 41: 572 { 573 @SuppressWarnings ("hiding") Token token = new41( 574 getText(accept_length), 575 start_line + 1, 576 start_pos + 1); 577 pushBack(accept_length); 578 this.pos = accept_pos; 579 this.line = accept_line; 580 return token; 581 } 582 case 42: 583 { 584 @SuppressWarnings ("hiding") Token token = new42( 585 getText(accept_length), 586 start_line + 1, 587 start_pos + 1); 588 pushBack(accept_length); 589 this.pos = accept_pos; 590 this.line = accept_line; 591 return token; 592 } 593 case 43: 594 { 595 @SuppressWarnings ("hiding") Token token = new43( 596 getText(accept_length), 597 start_line + 1, 598 start_pos + 1); 599 pushBack(accept_length); 600 this.pos = accept_pos; 601 this.line = accept_line; 602 return token; 603 } 604 case 44: 605 { 606 @SuppressWarnings ("hiding") Token token = new44( 607 getText(accept_length), 608 start_line + 1, 609 start_pos + 1); 610 pushBack(accept_length); 611 this.pos = accept_pos; 612 this.line = accept_line; 613 return token; 614 } 615 case 45: 616 { 617 @SuppressWarnings ("hiding") Token token = new45( 618 getText(accept_length), 619 start_line + 1, 620 start_pos + 1); 621 pushBack(accept_length); 622 this.pos = accept_pos; 623 this.line = accept_line; 624 return token; 625 } 626 case 46: 627 { 628 @SuppressWarnings ("hiding") Token token = new46( 629 getText(accept_length), 630 start_line + 1, 631 start_pos + 1); 632 pushBack(accept_length); 633 this.pos = accept_pos; 634 this.line = accept_line; 635 return token; 636 } 637 case 47: 638 { 639 @SuppressWarnings ("hiding") Token token = new47( 640 getText(accept_length), 641 start_line + 1, 642 start_pos + 1); 643 pushBack(accept_length); 644 this.pos = accept_pos; 645 this.line = accept_line; 646 return token; 647 } 648 case 48: 649 { 650 @SuppressWarnings ("hiding") Token token = new48( 651 getText(accept_length), 652 start_line + 1, 653 start_pos + 1); 654 pushBack(accept_length); 655 this.pos = accept_pos; 656 this.line = accept_line; 657 return token; 658 } 659 } 660 } 661 else 662 { 663 if(this.text.length() > 0) 664 { 665 throw new LexerException( 666 "[" + (start_line + 1) + "," + (start_pos + 1) + "]" + 667 " Unknown token: " + this.text); 668 } 669 670 @SuppressWarnings ("hiding") EOF token = new EOF( 671 start_line + 1, 672 start_pos + 1); 673 return token; 674 } 675 } 676 } 677 } 678 679 Token new0(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TAllKeyword(line, pos); } 680 Token new1(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TAnyKeyword(line, pos); } 681 Token new2(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TBackKeyword(line, pos); } 682 Token new3(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TExceptKeyword(line, pos); } 683 Token new4(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TGroupKeyword(line, pos); } 684 Token new5(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new THelpersKeyword(line, pos); } 685 Token new6(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TIgnoredKeyword(line, pos); } 686 Token new7(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TInfiniteKeyword(line, pos); } 687 Token new8(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TInternalKeyword(line, pos); } 688 Token new9(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TIntersectionKeyword(line, pos); } 689 Token new10(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TInvestigatorsKeyword(line, pos); } 690 Token new11(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TLanguageKeyword(line, pos); } 691 Token new12(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TLookaheadKeyword(line, pos); } 692 Token new13(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TLexerKeyword(line, pos); } 693 Token new14(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TNoneKeyword(line, pos); } 694 Token new15(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TOverKeyword(line, pos); } 695 Token new16(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TPrioritiesKeyword(line, pos); } 696 Token new17(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TShortestKeyword(line, pos); } 697 Token new18(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TStateKeyword(line, pos); } 698 Token new19(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TStatesKeyword(line, pos); } 699 Token new20(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TSyntaxKeyword(line, pos); } 700 Token new21(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TTokensKeyword(line, pos); } 701 Token new22(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TTransitionsKeyword(line, pos); } 702 Token new23(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TArrow(line, pos); } 703 Token new24(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TColon(line, pos); } 704 Token new25(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TComma(line, pos); } 705 Token new26(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TSemicolon(line, pos); } 706 Token new27(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TThreeDots(line, pos); } 707 Token new28(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TTwoDots(line, pos); } 708 Token new29(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TLeftParenthesis(line, pos); } 709 Token new30(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TRightParenthesis(line, pos); } 710 Token new31(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TAssign(line, pos); } 711 Token new32(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TBar(line, pos); } 712 Token new33(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TCaret(line, pos); } 713 Token new34(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TMinus(line, pos); } 714 Token new35(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TPlus(line, pos); } 715 Token new36(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TQuestionMark(line, pos); } 716 Token new37(@SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TStar(line, pos); } 717 Token new38(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TIdentifier(text, line, pos); } 718 Token new39(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TErroneousIdentifier(text, line, pos); } 719 Token new40(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TNumber(text, line, pos); } 720 Token new41(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TDecimalCharacter(text, line, pos); } 721 Token new42(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new THexadecimalCharacter(text, line, pos); } 722 Token new43(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TEmptyString(text, line, pos); } 723 Token new44(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TCharacterToken(text, line, pos); } 724 Token new45(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TString(text, line, pos); } 725 Token new46(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TLongComment(text, line, pos); } 726 Token new47(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TLineComment(text, line, pos); } 727 Token new48(@SuppressWarnings ("hiding") String text, @SuppressWarnings ("hiding") int line, @SuppressWarnings ("hiding") int pos) { return new TBlanks(text, line, pos); } 728 729 private int getChar() throws IOException 730 { 731 if(this.eof) 732 { 733 return -1; 734 } 735 736 int result = this.in.read(); 737 738 if(result == -1) 739 { 740 this.eof = true; 741 } 742 743 return result; 744 } 745 746 private void pushBack(int acceptLength) throws IOException 747 { 748 int length = this.text.length(); 749 for(int i = length - 1; i >= acceptLength; i--) 750 { 751 this.eof = false; 752 753 this.in.unread(this.text.charAt(i)); 754 } 755 } 756 757 protected void unread(@SuppressWarnings ("hiding") Token token) throws IOException 758 { 759 @SuppressWarnings ("hiding") String text = token.getText(); 760 int length = text.length(); 761 762 for(int i = length - 1; i >= 0; i--) 763 { 764 this.eof = false; 765 766 this.in.unread(text.charAt(i)); 767 } 768 769 this.pos = token.getPos() - 1; 770 this.line = token.getLine() - 1; 771 } 772 773 private String getText(int acceptLength) 774 { 775 StringBuffer s = new StringBuffer (acceptLength); 776 for(int i = 0; i < acceptLength; i++) 777 { 778 s.append(this.text.charAt(i)); 779 } 780 781 return s.toString(); 782 } 783 784 private static int[][][][] gotoTable; 785 984 985 private static int[][] accept; 986 991 992 public static class State 993 { 994 public final static State INITIAL = new State(0); 995 996 private int id; 997 998 private State(@SuppressWarnings ("hiding") int id) 999 { 1000 this.id = id; 1001 } 1002 1003 public int id() 1004 { 1005 return this.id; 1006 } 1007 } 1008 1009 static 1010 { 1011 try 1012 { 1013 DataInputStream s = new DataInputStream( 1014 new BufferedInputStream( 1015 Lexer.class.getResourceAsStream("lexer.dat"))); 1016 1017 int length = s.readInt(); 1019 gotoTable = new int[length][][][]; 1020 for(int i = 0; i < gotoTable.length; i++) 1021 { 1022 length = s.readInt(); 1023 gotoTable[i] = new int[length][][]; 1024 for(int j = 0; j < gotoTable[i].length; j++) 1025 { 1026 length = s.readInt(); 1027 gotoTable[i][j] = new int[length][3]; 1028 for(int k = 0; k < gotoTable[i][j].length; k++) 1029 { 1030 for(int l = 0; l < 3; l++) 1031 { 1032 gotoTable[i][j][k][l] = s.readInt(); 1033 } 1034 } 1035 } 1036 } 1037 1038 length = s.readInt(); 1040 accept = new int[length][]; 1041 for(int i = 0; i < accept.length; i++) 1042 { 1043 length = s.readInt(); 1044 accept[i] = new int[length]; 1045 for(int j = 0; j < accept[i].length; j++) 1046 { 1047 accept[i][j] = s.readInt(); 1048 } 1049 } 1050 1051 s.close(); 1052 } 1053 catch(Exception e) 1054 { 1055 throw new RuntimeException ("The file \"lexer.dat\" is either missing or corrupted."); 1056 } 1057 } 1058} 1059 | Popular Tags |