001/* 002 * Units of Measurement Implementation for Java SE 003 * Copyright (c) 2005-2017, Jean-Marie Dautelle, Werner Keil, V2COM. 004 * 005 * All rights reserved. 006 * 007 * Redistribution and use in source and binary forms, with or without modification, 008 * are permitted provided that the following conditions are met: 009 * 010 * 1. Redistributions of source code must retain the above copyright notice, 011 * this list of conditions and the following disclaimer. 012 * 013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 014 * and the following disclaimer in the documentation and/or other materials provided with the distribution. 015 * 016 * 3. Neither the name of JSR-363 nor the names of its contributors may be used to endorse or promote products 017 * derived from this software without specific prior written permission. 018 * 019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030/* Generated By:JavaCC: Do not edit this line. LocalUnitFormatParser.java */ 031package tec.uom.se.internal.format; 032 033import static tec.uom.se.internal.format.UnitTokenConstants.*; 034 035import javax.measure.Unit; 036 037import tec.uom.se.AbstractUnit; 038import tec.uom.se.format.SymbolMap; 039import tec.uom.se.function.LogConverter; 040import tec.uom.se.unit.MetricPrefix; 041 042/** 043 * @deprecated use {@link UnitFormatParser} FIXME there are some details e.g. Exception handling that are different, try to resolve or keep LUFP 044 */ 045@SuppressWarnings({ "rawtypes", "unchecked" }) 046public final class LocalUnitFormatParser { 047 048 private static class Exponent { 049 050 public final int pow; 051 052 public final int root; 053 054 public Exponent(int pow, int root) { 055 this.pow = pow; 056 this.root = root; 057 } 058 } 059 060 private SymbolMap symbols; 061 062 public LocalUnitFormatParser(SymbolMap symbols, java.io.Reader in) { 063 this(in); 064 this.symbols = symbols; 065 } 066 067 final public Unit parseUnit() throws TokenException { 068 Unit result = CompoundExpr(); 069 consumeToken(0); 070 { 071 return result; 072 } 073 } 074 075 final public Unit CompoundExpr() throws TokenException { 076 throw new UnsupportedOperationException("Compound units not supported"); 077 } 078 079 final public Unit AddExpr() throws TokenException { 080 Unit result = AbstractUnit.ONE; 081 Number n1 = null; 082 Token sign1 = null; 083 Number n2 = null; 084 Token sign2 = null; 085 if (jj_2_1(2147483647)) { 086 n1 = NumberExpr(); 087 sign1 = Sign(); 088 } else { 089 } 090 result = MulExpr(); 091 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 092 case PLUS: 093 case MINUS: 094 sign2 = Sign(); 095 n2 = NumberExpr(); 096 break; 097 default: 098 laA[1] = genInt; 099 } 100 if (n1 != null) { 101 if (sign1.image.equals("-")) { 102 result = result.multiply(-1); 103 } 104 result = result.shift(n1.doubleValue()); 105 } 106 if (n2 != null) { 107 double offset = n2.doubleValue(); 108 if (sign2.image.equals("-")) { 109 offset = -offset; 110 } 111 result = result.shift(offset); 112 } 113 { 114 return result; 115 } 116 } 117 118 final public Unit MulExpr() throws TokenException { 119 Unit result = AbstractUnit.ONE; 120 Unit temp = AbstractUnit.ONE; 121 result = ExponentExpr(); 122 label_2: while (true) { 123 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 124 case ASTERISK: 125 case MIDDLE_DOT: 126 case SOLIDUS: 127 break; 128 default: 129 laA[2] = genInt; 130 break label_2; 131 } 132 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 133 case ASTERISK: 134 case MIDDLE_DOT: 135 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 136 case ASTERISK: 137 consumeToken(ASTERISK); 138 break; 139 case MIDDLE_DOT: 140 consumeToken(MIDDLE_DOT); 141 break; 142 default: 143 laA[3] = genInt; 144 consumeToken(-1); 145 throw new TokenException(); 146 } 147 temp = ExponentExpr(); 148 result = result.multiply(temp); 149 break; 150 case SOLIDUS: 151 consumeToken(SOLIDUS); 152 temp = ExponentExpr(); 153 result = result.divide(temp); 154 break; 155 default: 156 laA[4] = genInt; 157 consumeToken(-1); 158 throw new TokenException(); 159 } 160 } 161 { 162 return result; 163 } 164 } 165 166 final public Unit ExponentExpr() throws TokenException { 167 Unit result = AbstractUnit.ONE; 168 Exponent exponent = null; 169 Token token = null; 170 if (jj_2_2(2147483647)) { 171 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 172 case INTEGER: 173 token = consumeToken(INTEGER); 174 break; 175 case E: 176 token = consumeToken(E); 177 break; 178 default: 179 laA[5] = genInt; 180 consumeToken(-1); 181 throw new TokenException(); 182 } 183 consumeToken(CARET); 184 result = AtomicExpr(); 185 double base; 186 if (token.kind == INTEGER) { 187 base = Integer.parseInt(token.image); 188 } else { 189 base = StrictMath.E; 190 } 191 { 192 return result.transform(new LogConverter(base).inverse()); 193 } 194 } else { 195 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 196 case OPEN_PAREN: 197 case INTEGER: 198 case FLOATING_POINT: 199 case UNIT_IDENTIFIER: 200 result = AtomicExpr(); 201 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 202 case CARET: 203 case SUPERSCRIPT_INTEGER: 204 exponent = Exp(); 205 break; 206 default: 207 laA[6] = genInt; 208 } 209 if (exponent != null) { 210 if (exponent.pow != 1) { 211 result = result.pow(exponent.pow); 212 } 213 if (exponent.root != 1) { 214 result = result.root(exponent.root); 215 } 216 } 217 { 218 return result; 219 } 220 case LOG: 221 case NAT_LOG: 222 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 223 case LOG: 224 consumeToken(LOG); 225 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 226 case INTEGER: 227 token = consumeToken(INTEGER); 228 break; 229 default: 230 laA[7] = genInt; 231 } 232 break; 233 case NAT_LOG: 234 token = consumeToken(NAT_LOG); 235 break; 236 default: 237 laA[8] = genInt; 238 consumeToken(-1); 239 throw new TokenException(); 240 } 241 consumeToken(OPEN_PAREN); 242 result = AddExpr(); 243 consumeToken(CLOSE_PAREN); 244 double base = 10; 245 if (token != null) { 246 if (token.kind == INTEGER) { 247 base = Integer.parseInt(token.image); 248 } else if (token.kind == NAT_LOG) { 249 base = StrictMath.E; 250 } 251 } 252 { 253 return result.transform(new LogConverter(base)); 254 } 255 default: 256 laA[9] = genInt; 257 consumeToken(-1); 258 throw new TokenException(); 259 } 260 } 261 } 262 263 final public Unit AtomicExpr() throws TokenException { 264 Unit result = AbstractUnit.ONE; 265 Number n = null; 266 Token token = null; 267 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 268 case INTEGER: 269 case FLOATING_POINT: 270 n = NumberExpr(); 271 if (n instanceof Integer) { 272 { 273 return result.multiply(n.intValue()); 274 } 275 } else { 276 { 277 return result.multiply(n.doubleValue()); 278 } 279 } 280 case UNIT_IDENTIFIER: 281 token = consumeToken(UNIT_IDENTIFIER); 282 Unit unit = symbols.getUnit(token.image); 283 if (unit == null) { 284 MetricPrefix prefix = symbols.getPrefix(token.image); 285 if (prefix != null) { 286 String prefixSymbol = symbols.getSymbol(prefix); 287 unit = symbols.getUnit(token.image.substring(prefixSymbol.length())); 288 if (unit != null) { 289 { 290 return unit.transform(prefix.getConverter()); 291 } 292 } 293 } 294 { 295 throw new TokenException(); 296 } 297 } else { 298 { 299 return unit; 300 } 301 } 302 case OPEN_PAREN: 303 consumeToken(OPEN_PAREN); 304 result = AddExpr(); 305 consumeToken(CLOSE_PAREN); 306 { 307 return result; 308 } 309 default: 310 laA[10] = genInt; 311 consumeToken(-1); 312 throw new TokenException(); 313 } 314 } 315 316 final public Token Sign() throws TokenException { 317 Token result = null; 318 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 319 case PLUS: 320 result = consumeToken(PLUS); 321 break; 322 case MINUS: 323 result = consumeToken(MINUS); 324 break; 325 default: 326 laA[11] = genInt; 327 consumeToken(-1); 328 throw new TokenException(); 329 } 330 { 331 return result; 332 } 333 } 334 335 final public Number NumberExpr() throws TokenException { 336 Token token = null; 337 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 338 case INTEGER: 339 token = consumeToken(INTEGER); 340 { 341 return Long.valueOf(token.image); 342 } 343 case FLOATING_POINT: 344 token = consumeToken(FLOATING_POINT); 345 { 346 return Double.valueOf(token.image); 347 } 348 default: 349 laA[12] = genInt; 350 consumeToken(-1); 351 throw new TokenException(); 352 } 353 } 354 355 final public Exponent Exp() throws TokenException { 356 Token powSign = null; 357 Token powToken = null; 358 Token rootSign = null; 359 Token rootToken = null; 360 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 361 case CARET: 362 consumeToken(CARET); 363 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 364 case PLUS: 365 case MINUS: 366 case INTEGER: 367 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 368 case PLUS: 369 case MINUS: 370 powSign = Sign(); 371 break; 372 default: 373 laA[13] = genInt; 374 } 375 powToken = consumeToken(INTEGER); 376 int pow = Integer.parseInt(powToken.image); 377 if ((powSign != null) && powSign.image.equals("-")) { 378 pow = -pow; 379 } 380 { 381 return new Exponent(pow, 1); 382 } 383 case OPEN_PAREN: 384 consumeToken(OPEN_PAREN); 385 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 386 case PLUS: 387 case MINUS: 388 powSign = Sign(); 389 break; 390 default: 391 laA[14] = genInt; 392 } 393 powToken = consumeToken(INTEGER); 394 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 395 case SOLIDUS: 396 consumeToken(SOLIDUS); 397 switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) { 398 case PLUS: 399 case MINUS: 400 rootSign = Sign(); 401 break; 402 default: 403 laA[15] = genInt; 404 } 405 rootToken = consumeToken(INTEGER); 406 break; 407 default: 408 laA[16] = genInt; 409 } 410 consumeToken(CLOSE_PAREN); 411 pow = Integer.parseInt(powToken.image); 412 if ((powSign != null) && powSign.image.equals("-")) { 413 pow = -pow; 414 } 415 int root = 1; 416 if (rootToken != null) { 417 root = Integer.parseInt(rootToken.image); 418 if ((rootSign != null) && rootSign.image.equals("-")) { 419 root = -root; 420 } 421 } 422 { 423 return new Exponent(pow, root); 424 } 425 default: 426 laA[17] = genInt; 427 consumeToken(-1); 428 throw new TokenException(); 429 } 430 case SUPERSCRIPT_INTEGER: 431 powToken = consumeToken(SUPERSCRIPT_INTEGER); 432 int pow = 0; 433 for (int i = 0; i < powToken.image.length(); i += 1) { 434 pow *= 10; 435 switch (powToken.image.charAt(i)) { 436 case '\u00b9': 437 pow += 1; 438 break; 439 case '\u00b2': 440 pow += 2; 441 break; 442 case '\u00b3': 443 pow += 3; 444 break; 445 case '\u2074': 446 pow += 4; 447 break; 448 case '\u2075': 449 pow += 5; 450 break; 451 case '\u2076': 452 pow += 6; 453 break; 454 case '\u2077': 455 pow += 7; 456 break; 457 case '\u2078': 458 pow += 8; 459 break; 460 case '\u2079': 461 pow += 9; 462 break; 463 } 464 } 465 { 466 return new Exponent(pow, 1); 467 } 468 default: 469 laA[18] = genInt; 470 consumeToken(-1); 471 throw new TokenException(); 472 } 473 } 474 475 private boolean jj_2_1(int xla) { 476 laInt = xla; 477 lastpos = scanpos = token; 478 try { 479 return !jj_3_1(); 480 } catch (LookaheadSuccess ls) { 481 return true; 482 } finally { 483 jj_save(0, xla); 484 } 485 } 486 487 private boolean jj_2_2(int xla) { 488 laInt = xla; 489 lastpos = scanpos = token; 490 try { 491 return !jj_3_2(); 492 } catch (LookaheadSuccess ls) { 493 return true; 494 } finally { 495 jj_save(1, xla); 496 } 497 } 498 499 private boolean jj_3R_3() { 500 Token xsp; 501 xsp = scanpos; 502 if (jj_3R_5()) { 503 scanpos = xsp; 504 if (jj_3R_6()) 505 return true; 506 } 507 return false; 508 } 509 510 private boolean jj_3R_6() { 511 return scanToken(FLOATING_POINT); 512 } 513 514 private boolean jj_3_2() { 515 Token xsp; 516 xsp = scanpos; 517 if (scanToken(14)) { 518 scanpos = xsp; 519 if (scanToken(19)) 520 return true; 521 } 522 return scanToken(CARET); 523 } 524 525 private boolean jj_3_1() { 526 return jj_3R_3() || jj_3R_4(); 527 } 528 529 private boolean jj_3R_4() { 530 Token xsp; 531 xsp = scanpos; 532 if (scanToken(5)) { 533 scanpos = xsp; 534 if (scanToken(6)) 535 return true; 536 } 537 return false; 538 } 539 540 private boolean jj_3R_5() { 541 return scanToken(INTEGER); 542 } 543 544 /** Generated Token Manager. */ 545 public UnitTokenManager tokenSource; 546 547 DefaultCharStream inputStream; 548 549 /** Current token. */ 550 public Token token; 551 552 /** Next token. */ 553 public Token nextToken; 554 555 private int nextTokenIndex; 556 557 private Token scanpos, lastpos; 558 559 private int laInt; 560 561 private int genInt; 562 563 final private int[] laA = new int[19]; 564 565 static private int[] laB; 566 567 static { 568 init(); 569 } 570 571 private static void init() { 572 laB = new int[] { 0x800, 0x60, 0x380, 0x180, 0x380, 0x84000, 0x8400, 0x4000, 0x60000, 0x175000, 0x115000, 0x60, 0x14000, 0x60, 0x60, 0x60, 0x200, 573 0x5060, 0x8400, }; 574 } 575 576 final private JJCalls[] rtns = new JJCalls[2]; 577 578 private boolean rescan = false; 579 580 private int gcInt = 0; 581 582 /** Constructor with InputStream. */ 583 public LocalUnitFormatParser(java.io.InputStream stream) { 584 this(stream, null); 585 } 586 587 /** Constructor with InputStream and supplied encoding */ 588 public LocalUnitFormatParser(java.io.InputStream stream, String encoding) { 589 try { 590 inputStream = new DefaultCharStream(stream, encoding, 1, 1); 591 } catch (java.io.UnsupportedEncodingException e) { 592 throw new RuntimeException(e); 593 } 594 tokenSource = new UnitTokenManager(inputStream); 595 token = new Token(); 596 nextTokenIndex = -1; 597 genInt = 0; 598 for (int i = 0; i < 19; i++) { 599 laA[i] = -1; 600 } 601 for (int i = 0; i < rtns.length; i++) { 602 rtns[i] = new JJCalls(); 603 } 604 } 605 606 /** Reinitialise. */ 607 public void ReInit(java.io.InputStream stream) { 608 ReInit(stream, null); 609 } 610 611 /** Reinitialise. */ 612 public void ReInit(java.io.InputStream stream, String encoding) { 613 try { 614 inputStream.ReInit(stream, encoding, 1, 1); 615 } catch (java.io.UnsupportedEncodingException e) { 616 throw new RuntimeException(e); 617 } 618 tokenSource.ReInit(inputStream); 619 token = new Token(); 620 nextTokenIndex = -1; 621 genInt = 0; 622 for (int i = 0; i < 19; i++) { 623 laA[i] = -1; 624 } 625 for (int i = 0; i < rtns.length; i++) { 626 rtns[i] = new JJCalls(); 627 } 628 } 629 630 /** Constructor. */ 631 public LocalUnitFormatParser(java.io.Reader stream) { 632 inputStream = new DefaultCharStream(stream, 1, 1); 633 tokenSource = new UnitTokenManager(inputStream); 634 token = new Token(); 635 nextTokenIndex = -1; 636 genInt = 0; 637 for (int i = 0; i < 19; i++) { 638 laA[i] = -1; 639 } 640 for (int i = 0; i < rtns.length; i++) { 641 rtns[i] = new JJCalls(); 642 } 643 } 644 645 /** Reinitialise. */ 646 public void ReInit(java.io.Reader stream) { 647 inputStream.ReInit(stream, 1, 1); 648 tokenSource.ReInit(inputStream); 649 token = new Token(); 650 nextTokenIndex = -1; 651 genInt = 0; 652 for (int i = 0; i < 19; i++) { 653 laA[i] = -1; 654 } 655 for (int i = 0; i < rtns.length; i++) { 656 rtns[i] = new JJCalls(); 657 } 658 } 659 660 /** Constructor with generated Token Manager. */ 661 public LocalUnitFormatParser(UnitTokenManager tm) { 662 tokenSource = tm; 663 token = new Token(); 664 nextTokenIndex = -1; 665 genInt = 0; 666 for (int i = 0; i < 19; i++) { 667 laA[i] = -1; 668 } 669 for (int i = 0; i < rtns.length; i++) { 670 rtns[i] = new JJCalls(); 671 } 672 } 673 674 /** Reinitialise. */ 675 public void ReInit(UnitTokenManager tm) { 676 tokenSource = tm; 677 token = new Token(); 678 nextTokenIndex = -1; 679 genInt = 0; 680 for (int i = 0; i < 19; i++) { 681 laA[i] = -1; 682 } 683 for (int i = 0; i < rtns.length; i++) { 684 rtns[i] = new JJCalls(); 685 } 686 } 687 688 private Token consumeToken(int kind) throws TokenException { 689 Token oldToken; 690 if ((oldToken = token).next != null) 691 token = token.next; 692 else 693 token = token.next = tokenSource.getNextToken(); 694 nextTokenIndex = -1; 695 if (token.kind == kind) { 696 genInt++; 697 if (++gcInt > 100) { 698 gcInt = 0; 699 for (JJCalls jj_2_rtn : rtns) { 700 JJCalls c = jj_2_rtn; 701 while (c != null) { 702 if (c.gen < genInt) 703 c.first = null; 704 c = c.next; 705 } 706 } 707 } 708 return token; 709 } 710 token = oldToken; 711 this.kind = kind; 712 throw raiseTokenException(); 713 } 714 715 static private final class LookaheadSuccess extends java.lang.RuntimeException { 716 private static final long serialVersionUID = 2205332054119123041L; 717 } 718 719 private boolean scanToken(int kind) { 720 if (scanpos == lastpos) { 721 laInt--; 722 if (scanpos.next == null) { 723 lastpos = scanpos = scanpos.next = tokenSource.getNextToken(); 724 } else { 725 lastpos = scanpos = scanpos.next; 726 } 727 } else { 728 scanpos = scanpos.next; 729 } 730 if (rescan) { 731 int i = 0; 732 Token tok = token; 733 while (tok != null && tok != scanpos) { 734 i++; 735 tok = tok.next; 736 } 737 if (tok != null) 738 jj_add_error_token(kind, i); 739 } 740 if (scanpos.kind != kind) 741 return true; 742 if (laInt == 0 && scanpos == lastpos) 743 throw new LookaheadSuccess(); 744 return false; 745 } 746 747 /** Get the next Token. */ 748 final public Token getNextToken() { 749 if (token.next != null) 750 token = token.next; 751 else 752 token = token.next = tokenSource.getNextToken(); 753 nextTokenIndex = -1; 754 genInt++; 755 return token; 756 } 757 758 /** Get the specific Token. */ 759 final public Token getToken(int index) { 760 Token t = token; 761 for (int i = 0; i < index; i++) { 762 if (t.next != null) 763 t = t.next; 764 else 765 t = t.next = tokenSource.getNextToken(); 766 } 767 return t; 768 } 769 770 private int jj_ntk() { 771 if ((nextToken = token.next) == null) { 772 return (nextTokenIndex = (token.next = tokenSource.getNextToken()).kind); 773 } else { 774 return (nextTokenIndex = nextToken.kind); 775 } 776 } 777 778 private final java.util.List<int[]> expentries = new java.util.ArrayList<>(); 779 780 private int[] expentry; 781 782 private int kind = -1; 783 784 private final int[] lastTokens = new int[100]; 785 786 private int endpos; 787 788 private void jj_add_error_token(int kind, int pos) { 789 if (pos >= 100) 790 return; 791 if (pos == endpos + 1) { 792 lastTokens[endpos++] = kind; 793 } else if (endpos != 0) { 794 expentry = new int[endpos]; 795 System.arraycopy(lastTokens, 0, expentry, 0, endpos); 796 entriesLoop: for (int[] jj_expentry1 : expentries) { 797 if (jj_expentry1.length == expentry.length) { 798 for (int i = 0; i < expentry.length; i++) { 799 if (jj_expentry1[i] != expentry[i]) { 800 continue entriesLoop; 801 } 802 } 803 expentries.add(expentry); 804 break; 805 } 806 } 807 if (pos != 0) 808 lastTokens[(endpos = pos) - 1] = kind; 809 } 810 } 811 812 /** Generate TokenException. */ 813 TokenException raiseTokenException() { 814 expentries.clear(); 815 boolean[] la1tokens = new boolean[21]; 816 if (kind >= 0) { 817 la1tokens[kind] = true; 818 kind = -1; 819 } 820 for (int i = 0; i < 19; i++) { 821 if (laA[i] == genInt) { 822 for (int j = 0; j < 32; j++) { 823 if ((laB[i] & (1 << j)) != 0) { 824 la1tokens[j] = true; 825 } 826 } 827 } 828 } 829 for (int i = 0; i < 21; i++) { 830 if (la1tokens[i]) { 831 expentry = new int[1]; 832 expentry[0] = i; 833 expentries.add(expentry); 834 } 835 } 836 endpos = 0; 837 jj_rescan_token(); 838 jj_add_error_token(0, 0); 839 int[][] exptokseq = new int[expentries.size()][]; 840 for (int i = 0; i < expentries.size(); i++) { 841 exptokseq[i] = expentries.get(i); 842 } 843 return new TokenException(token, exptokseq, tokenImage); 844 } 845 846 /** Enable tracing. */ 847 final public void enable_tracing() { 848 } 849 850 /** Disable tracing. */ 851 final public void disable_tracing() { 852 } 853 854 private void jj_rescan_token() { 855 rescan = true; 856 for (int i = 0; i < 2; i++) { 857 try { 858 JJCalls p = rtns[i]; 859 do { 860 if (p.gen > genInt) { 861 laInt = p.arg; 862 lastpos = scanpos = p.first; 863 switch (i) { 864 case 0: 865 jj_3_1(); 866 break; 867 case 1: 868 jj_3_2(); 869 break; 870 } 871 } 872 p = p.next; 873 } while (p != null); 874 } catch (LookaheadSuccess ls) { 875 } 876 } 877 rescan = false; 878 } 879 880 private void jj_save(int index, int xla) { 881 JJCalls p = rtns[index]; 882 while (p.gen > genInt) { 883 if (p.next == null) { 884 p = p.next = new JJCalls(); 885 break; 886 } 887 p = p.next; 888 } 889 p.gen = genInt + xla - laInt; 890 p.first = token; 891 p.arg = xla; 892 } 893 894 static final class JJCalls { 895 896 int gen; 897 898 Token first; 899 900 int arg; 901 902 JJCalls next; 903 904 } 905}