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