/* Generated By:JavaCC: Do not edit this line. SiteswapParser.java */
package jugglinglab.notation;

// This file is part of Juggling Lab.  It was automatically generated by JavaCC
// from the grammar file "SiteswapParser.jj".
//
// DO NOT EDIT THIS FILE DIRECTLY, AS YOUR CHANGES WILL LIKELY BE OVERWRITTEN

public class SiteswapParser implements SiteswapParserConstants {
        private static int jugglers;
        private static int current_juggler;
        private static int current_beat;
        private static int current_beat_sub;

        public static SiteswapTreeItem parsePattern(String pat) throws ParseException {
                java.io.StringReader sr = new java.io.StringReader(pat);
                java.io.Reader r = new java.io.BufferedReader(sr);
                SiteswapParser parser = new SiteswapParser(r);
                jugglers = -1;
                return (parser.MakeTree());
        }

        // For test purposes
        public static void main(String args[]) throws ParseException {
                String in = args[0];
                System.out.println("parsing pattern: "+in);
                System.out.println(parsePattern(in));
        }

  final public SiteswapTreeItem MakeTree() throws ParseException {
  SiteswapTreeItem b;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SPC:
      jj_consume_token(SPC);
      break;
    default:
      jj_la1[0] = jj_gen;
      ;
    }
    b = Pattern();
    jj_consume_token(0);
          {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem Pattern() throws ParseException {
  SiteswapTreeItem b, c; int n;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_PATTERN);
    label_1:
    while (true) {
      if (jj_2_1(2147483647)) {
        c = GroupedPattern();
      } else {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case NUM:
        case LET:
        case 9:
        case 14:
        case 16:
        case 18:
        case 19:
        case 21:
        case 22:
          c = SoloSequence();
          break;
        case 23:
          c = PassingSequence();
          break;
        case 26:
          n = Wildcard();
                                        c = new SiteswapTreeItem(SiteswapTreeItem.TYPE_WILDCARD);
                                        c.beats = n;
          break;
        default:
          jj_la1[1] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
                  b.addChild(c);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case NUM:
      case LET:
      case 9:
      case 14:
      case 16:
      case 18:
      case 19:
      case 21:
      case 22:
      case 23:
      case 26:
        ;
        break;
      default:
        jj_la1[2] = jj_gen;
        break label_1;
      }
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 8:
      jj_consume_token(8);
                  b.switchrepeat = true;
      break;
    default:
      jj_la1[3] = jj_gen;
      ;
    }
                b.jugglers = jugglers;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem GroupedPattern() throws ParseException {
  SiteswapTreeItem b, c; int n;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_GROUPED_PATTERN);
    jj_consume_token(9);
    c = Pattern();
                        b.addChild(c);
                        b.repeats = 1;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 10:
      jj_consume_token(10);
      n = Number();
                  b.repeats = n;
      break;
    default:
      jj_la1[4] = jj_gen;
      ;
    }
    jj_consume_token(11);
          {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem SoloSequence() throws ParseException {
  SiteswapTreeItem b, c; Token s=null;
                b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_SOLO_SEQUENCE);
                current_juggler = 1;
                current_beat = 0;
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case NUM:
      case LET:
      case 14:
      case 16:
      case 18:
      case 19:
        c = SoloMultiThrow();
                                        current_beat++;
                                        b.addChild(c);
        break;
      case 9:
        c = SoloPairedThrow();
                                  current_beat += 2;
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case 12:
          jj_consume_token(12);
                                  current_beat--;
          break;
        default:
          jj_la1[5] = jj_gen;
          ;
        }
                                  b.addChild(c);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[6] = jj_gen;
          ;
        }
        break;
      case 21:
      case 22:
        c = SoloHandSpecifier();
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[7] = jj_gen;
          ;
        }
                                  b.addChild(c);
        break;
      default:
        jj_la1[8] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      if (jj_2_2(2147483647)) {
        ;
      } else {
        break label_2;
      }
    }
                if (jugglers == -1)
                        jugglers = 1;
                else if (jugglers != 1) {
                        {if (true) throw new ParseException("Inconsistent number of jugglers");}
                }
                b.source_juggler = 1;
                b.beats = current_beat;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem SoloPairedThrow() throws ParseException {
  SiteswapTreeItem b, c;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_SOLO_PAIRED_THROW);
    jj_consume_token(9);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SPC:
      jj_consume_token(SPC);
      break;
    default:
      jj_la1[9] = jj_gen;
      ;
    }
    c = SoloMultiThrow();
                  b.addChild(c);
    jj_consume_token(13);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SPC:
      jj_consume_token(SPC);
      break;
    default:
      jj_la1[10] = jj_gen;
      ;
    }
    c = SoloMultiThrow();
                  b.addChild(c);
    jj_consume_token(11);
                b.source_juggler = 1;
                b.seq_beatnum = current_beat;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem SoloMultiThrow() throws ParseException {
  SiteswapTreeItem b, c;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_SOLO_MULTI_THROW);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case NUM:
    case LET:
    case 18:
    case 19:
      c = SoloSingleThrow();
                          b.addChild(c);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[11] = jj_gen;
        ;
      }
      break;
    case 14:
      jj_consume_token(14);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[12] = jj_gen;
        ;
      }
      label_3:
      while (true) {
        c = SoloSingleThrow();
                                  b.addChild(c);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[13] = jj_gen;
          ;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case NUM:
        case LET:
        case 18:
        case 19:
          ;
          break;
        default:
          jj_la1[14] = jj_gen;
          break label_3;
        }
      }
      jj_consume_token(15);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[15] = jj_gen;
        ;
      }
      break;
    case 16:
      jj_consume_token(16);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[16] = jj_gen;
        ;
      }
      label_4:
      while (true) {
        c = SoloSingleThrow();
                                  b.addChild(c);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[17] = jj_gen;
          ;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case NUM:
        case LET:
        case 18:
        case 19:
          ;
          break;
        default:
          jj_la1[18] = jj_gen;
          break label_4;
        }
      }
      jj_consume_token(17);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[19] = jj_gen;
        ;
      }
      break;
    default:
      jj_la1[20] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                b.source_juggler = 1;
                b.seq_beatnum = current_beat;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem SoloSingleThrow() throws ParseException {
  SiteswapTreeItem b; Token t; String mod;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_SOLO_SINGLE_THROW);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case NUM:
      t = jj_consume_token(NUM);
                                  b.value = Character.digit((t.image.toCharArray())[0], 36);
      break;
    case LET:
      t = jj_consume_token(LET);
                                  b.value = Character.digit((t.image.toCharArray())[0], 36);
      break;
    case 18:
      jj_consume_token(18);
                                  b.value = 25;
      break;
    case 19:
      jj_consume_token(19);
                                  b.value = 33;
      break;
    default:
      jj_la1[21] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 19:
      jj_consume_token(19);
                          b.x = true;
      break;
    default:
      jj_la1[22] = jj_gen;
      ;
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case MOD:
      mod = Modifier();
                          b.mod = mod;
      break;
    default:
      jj_la1[23] = jj_gen;
      ;
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 20:
      jj_consume_token(20);
      break;
    default:
      jj_la1[24] = jj_gen;
      ;
    }
                b.source_juggler = 1;
                b.dest_juggler = 1;
                b.seq_beatnum = current_beat;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem SoloHandSpecifier() throws ParseException {
  SiteswapTreeItem b;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_HAND_SPEC);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 21:
      jj_consume_token(21);
                          b.spec_left = false;
      break;
    case 22:
      jj_consume_token(22);
                          b.spec_left = true;
      break;
    default:
      jj_la1[25] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                b.source_juggler = 1;
                b.seq_beatnum = current_beat;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem PassingSequence() throws ParseException {
  SiteswapTreeItem b, c;
                b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_PASSING_SEQUENCE);
                current_beat = 0;
    label_5:
    while (true) {
      c = PassingGroup();
                                b.jugglers = c.jugglers;
                                b.addChild(c);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 23:
        ;
        break;
      default:
        jj_la1[26] = jj_gen;
        break label_5;
      }
    }
                b.beats = current_beat;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem PassingGroup() throws ParseException {
  SiteswapTreeItem b, c;
                b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_PASSING_GROUP);
                current_juggler = 1;
    jj_consume_token(23);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SPC:
      jj_consume_token(SPC);
      break;
    default:
      jj_la1[27] = jj_gen;
      ;
    }
    c = PassingThrows();
                        b.beats = c.beats;
                        b.addChild(c);
                        current_juggler++;
    label_6:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 24:
        ;
        break;
      default:
        jj_la1[28] = jj_gen;
        break label_6;
      }
      jj_consume_token(24);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[29] = jj_gen;
        ;
      }
      c = PassingThrows();
                                if (c.beats != b.beats) {
                                        {if (true) throw new ParseException("Inconsistent number of beats between jugglers");}
                                }
                                b.addChild(c);
                                current_juggler++;
    }
    jj_consume_token(25);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SPC:
      jj_consume_token(SPC);
      break;
    default:
      jj_la1[30] = jj_gen;
      ;
    }
                b.jugglers = current_juggler - 1;
                if (jugglers == -1)
                        jugglers = b.jugglers;
                else if (b.jugglers != jugglers) {
                        {if (true) throw new ParseException("Inconsistent number of jugglers");}
                }
                b.seq_beatnum = current_beat;
                current_beat += b.beats;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem PassingThrows() throws ParseException {
  SiteswapTreeItem b, c;
                b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_PASSING_THROWS);
                current_beat_sub = 0;
    label_7:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case NUM:
      case LET:
      case 14:
      case 16:
      case 18:
      case 19:
        c = PassingMultiThrow();
                                        current_beat_sub++;
                                        b.addChild(c);
        break;
      case 9:
        c = PassingPairedThrow();
                                  current_beat_sub += 2;
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case 12:
          jj_consume_token(12);
                                  current_beat_sub--;
          break;
        default:
          jj_la1[31] = jj_gen;
          ;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[32] = jj_gen;
          ;
        }
                                  b.addChild(c);
        break;
      case 21:
      case 22:
        c = PassingHandSpecifier();
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[33] = jj_gen;
          ;
        }
                                  b.addChild(c);
        break;
      default:
        jj_la1[34] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      if (jj_2_3(2147483647)) {
        ;
      } else {
        break label_7;
      }
    }
                b.source_juggler = current_juggler;
                b.beats = current_beat_sub;
                b.seq_beatnum = current_beat;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem PassingPairedThrow() throws ParseException {
  SiteswapTreeItem b, c;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_PASSING_PAIRED_THROW);
    jj_consume_token(9);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SPC:
      jj_consume_token(SPC);
      break;
    default:
      jj_la1[35] = jj_gen;
      ;
    }
    c = PassingMultiThrow();
                  b.addChild(c);
    jj_consume_token(13);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SPC:
      jj_consume_token(SPC);
      break;
    default:
      jj_la1[36] = jj_gen;
      ;
    }
    c = PassingMultiThrow();
                  b.addChild(c);
    jj_consume_token(11);
                b.source_juggler = current_juggler;
                b.seq_beatnum = current_beat + current_beat_sub;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem PassingMultiThrow() throws ParseException {
  SiteswapTreeItem b, c;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_PASSING_MULTI_THROW);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case NUM:
    case LET:
    case 18:
    case 19:
      c = PassingSingleThrow();
                          b.addChild(c);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[37] = jj_gen;
        ;
      }
      break;
    case 14:
      jj_consume_token(14);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[38] = jj_gen;
        ;
      }
      label_8:
      while (true) {
        c = PassingSingleThrow();
                                  b.addChild(c);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[39] = jj_gen;
          ;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case NUM:
        case LET:
        case 18:
        case 19:
          ;
          break;
        default:
          jj_la1[40] = jj_gen;
          break label_8;
        }
      }
      jj_consume_token(15);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[41] = jj_gen;
        ;
      }
      break;
    case 16:
      jj_consume_token(16);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[42] = jj_gen;
        ;
      }
      label_9:
      while (true) {
        c = PassingSingleThrow();
                                  b.addChild(c);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case SPC:
          jj_consume_token(SPC);
          break;
        default:
          jj_la1[43] = jj_gen;
          ;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case NUM:
        case LET:
        case 18:
        case 19:
          ;
          break;
        default:
          jj_la1[44] = jj_gen;
          break label_9;
        }
      }
      jj_consume_token(17);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SPC:
        jj_consume_token(SPC);
        break;
      default:
        jj_la1[45] = jj_gen;
        ;
      }
      break;
    default:
      jj_la1[46] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                b.source_juggler = current_juggler;
                b.seq_beatnum = current_beat + current_beat_sub;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem PassingSingleThrow() throws ParseException {
  SiteswapTreeItem b, c; Token t; int dest, d; String mod;
                b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_PASSING_SINGLE_THROW);
                dest = current_juggler;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case NUM:
      t = jj_consume_token(NUM);
                                  b.value = Character.digit((t.image.toCharArray())[0], 36);
      break;
    case LET:
      t = jj_consume_token(LET);
                                  b.value = Character.digit((t.image.toCharArray())[0], 36);
      break;
    case 18:
      jj_consume_token(18);
                                  b.value = 25;
      break;
    case 19:
      jj_consume_token(19);
                                  b.value = 33;
      break;
    default:
      jj_la1[47] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 19:
      jj_consume_token(19);
                          b.x = true;
      break;
    default:
      jj_la1[48] = jj_gen;
      ;
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 18:
      jj_consume_token(18);
                          dest = current_juggler + 1;
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case NUM:
        d = Number();
                          dest = d;
        break;
      default:
        jj_la1[49] = jj_gen;
        ;
      }
      break;
    default:
      jj_la1[50] = jj_gen;
      ;
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case MOD:
      mod = Modifier();
                          b.mod = mod;
      break;
    default:
      jj_la1[51] = jj_gen;
      ;
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 20:
      jj_consume_token(20);
      break;
    default:
      jj_la1[52] = jj_gen;
      ;
    }
                b.source_juggler = current_juggler;
                b.dest_juggler = dest;
                b.seq_beatnum = current_beat + current_beat_sub;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public SiteswapTreeItem PassingHandSpecifier() throws ParseException {
  SiteswapTreeItem b;
          b = new SiteswapTreeItem(SiteswapTreeItem.TYPE_HAND_SPEC);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 21:
      jj_consume_token(21);
                          b.spec_left = false;
      break;
    case 22:
      jj_consume_token(22);
                          b.spec_left = true;
      break;
    default:
      jj_la1[53] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                b.source_juggler = current_juggler;
                b.seq_beatnum = current_beat + current_beat_sub;
                {if (true) return b;}
    throw new Error("Missing return statement in function");
  }

  final public int Number() throws ParseException {
  Token n; String s = "";
    label_10:
    while (true) {
      n = jj_consume_token(NUM);
                          s += n.image;
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case NUM:
        ;
        break;
      default:
        jj_la1[54] = jj_gen;
        break label_10;
      }
    }
                int val = -1;
                try {
                        val = Integer.parseInt(s);
                } catch (NumberFormatException mfe) {
                }
                {if (true) return val;}
    throw new Error("Missing return statement in function");
  }

  final public int Wildcard() throws ParseException {
  int beats = 0;
    label_11:
    while (true) {
      jj_consume_token(26);
                  beats++;
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 26:
        ;
        break;
      default:
        jj_la1[55] = jj_gen;
        break label_11;
      }
    }
          {if (true) return beats;}
    throw new Error("Missing return statement in function");
  }

  final public String Modifier() throws ParseException {
  Token t; String mod = "";
    t = jj_consume_token(MOD);
                  mod += t.image;
    label_12:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case MOD:
      case 21:
      case 22:
        ;
        break;
      default:
        jj_la1[56] = jj_gen;
        break label_12;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case MOD:
        t = jj_consume_token(MOD);
                          mod += t.image;
        break;
      case 22:
        jj_consume_token(22);
                          mod += "L";
        break;
      case 21:
        jj_consume_token(21);
                          mod += "R";
        break;
      default:
        jj_la1[57] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
          {if (true) return mod;}
    throw new Error("Missing return statement in function");
  }

  private boolean jj_2_1(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_1(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(0, xla); }
  }

  private boolean jj_2_2(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_2(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(1, xla); }
  }

  private boolean jj_2_3(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_3(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(2, xla); }
  }

  private boolean jj_3R_74() {
    if (jj_3R_23()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_78()) jj_scanpos = xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_84() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_85()) {
    jj_scanpos = xsp;
    if (jj_3R_86()) {
    jj_scanpos = xsp;
    if (jj_3R_87()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_14() {
    if (jj_3R_22()) return true;
    return false;
  }

  private boolean jj_3_2() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_14()) {
    jj_scanpos = xsp;
    if (jj_3R_15()) {
    jj_scanpos = xsp;
    if (jj_3R_16()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_73() {
    if (jj_3R_22()) return true;
    return false;
  }

  private boolean jj_3R_68() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_73()) {
    jj_scanpos = xsp;
    if (jj_3R_74()) {
    jj_scanpos = xsp;
    if (jj_3R_75()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_79() {
    Token xsp;
    if (jj_3R_84()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_84()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  private boolean jj_3R_83() {
    if (jj_scan_token(21)) return true;
    return false;
  }

  private boolean jj_3R_82() {
    if (jj_scan_token(22)) return true;
    return false;
  }

  private boolean jj_3R_81() {
    if (jj_scan_token(MOD)) return true;
    return false;
  }

  private boolean jj_3R_77() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_81()) {
    jj_scanpos = xsp;
    if (jj_3R_82()) {
    jj_scanpos = xsp;
    if (jj_3R_83()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_52() {
    Token xsp;
    if (jj_3R_68()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_68()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  private boolean jj_3R_80() {
    if (jj_scan_token(24)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_79()) return true;
    return false;
  }

  private boolean jj_3R_71() {
    if (jj_scan_token(MOD)) return true;
    Token xsp;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_77()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  private boolean jj_3R_21() {
    if (jj_scan_token(10)) return true;
    if (jj_3R_30()) return true;
    return false;
  }

  private boolean jj_3R_13() {
    if (jj_scan_token(9)) return true;
    if (jj_3R_20()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_21()) jj_scanpos = xsp;
    if (jj_scan_token(11)) return true;
    return false;
  }

  private boolean jj_3R_70() {
    if (jj_scan_token(26)) return true;
    return false;
  }

  private boolean jj_3_1() {
    if (jj_3R_13()) return true;
    return false;
  }

  private boolean jj_3R_54() {
    Token xsp;
    if (jj_3R_70()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_70()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  private boolean jj_3R_44() {
    if (jj_3R_54()) return true;
    return false;
  }

  private boolean jj_3R_43() {
    if (jj_3R_53()) return true;
    return false;
  }

  private boolean jj_3R_42() {
    if (jj_3R_52()) return true;
    return false;
  }

  private boolean jj_3R_76() {
    if (jj_scan_token(23)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_79()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_80()) { jj_scanpos = xsp; break; }
    }
    if (jj_scan_token(25)) return true;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_45() {
    if (jj_scan_token(NUM)) return true;
    return false;
  }

  private boolean jj_3R_41() {
    if (jj_3R_13()) return true;
    return false;
  }

  private boolean jj_3R_29() {
    if (jj_scan_token(8)) return true;
    return false;
  }

  private boolean jj_3R_69() {
    if (jj_3R_76()) return true;
    return false;
  }

  private boolean jj_3R_30() {
    Token xsp;
    if (jj_3R_45()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_45()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  private boolean jj_3R_28() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_41()) {
    jj_scanpos = xsp;
    if (jj_3R_42()) {
    jj_scanpos = xsp;
    if (jj_3R_43()) {
    jj_scanpos = xsp;
    if (jj_3R_44()) return true;
    }
    }
    }
    return false;
  }

  private boolean jj_3R_40() {
    if (jj_scan_token(22)) return true;
    return false;
  }

  private boolean jj_3R_39() {
    if (jj_scan_token(21)) return true;
    return false;
  }

  private boolean jj_3R_20() {
    Token xsp;
    if (jj_3R_28()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_28()) { jj_scanpos = xsp; break; }
    }
    xsp = jj_scanpos;
    if (jj_3R_29()) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_53() {
    Token xsp;
    if (jj_3R_69()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_69()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  private boolean jj_3R_35() {
    if (jj_scan_token(22)) return true;
    return false;
  }

  private boolean jj_3R_27() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_39()) {
    jj_scanpos = xsp;
    if (jj_3R_40()) return true;
    }
    return false;
  }

  private boolean jj_3R_34() {
    if (jj_scan_token(21)) return true;
    return false;
  }

  private boolean jj_3R_67() {
    if (jj_3R_71()) return true;
    return false;
  }

  private boolean jj_3R_66() {
    if (jj_scan_token(18)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_72()) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_72() {
    if (jj_3R_30()) return true;
    return false;
  }

  private boolean jj_3R_64() {
    if (jj_scan_token(19)) return true;
    return false;
  }

  private boolean jj_3R_63() {
    if (jj_scan_token(18)) return true;
    return false;
  }

  private boolean jj_3R_65() {
    if (jj_scan_token(19)) return true;
    return false;
  }

  private boolean jj_3R_24() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_34()) {
    jj_scanpos = xsp;
    if (jj_3R_35()) return true;
    }
    return false;
  }

  private boolean jj_3R_62() {
    if (jj_scan_token(LET)) return true;
    return false;
  }

  private boolean jj_3R_60() {
    if (jj_3R_71()) return true;
    return false;
  }

  private boolean jj_3R_58() {
    if (jj_scan_token(19)) return true;
    return false;
  }

  private boolean jj_3R_61() {
    if (jj_scan_token(NUM)) return true;
    return false;
  }

  private boolean jj_3R_57() {
    if (jj_scan_token(18)) return true;
    return false;
  }

  private boolean jj_3R_59() {
    if (jj_scan_token(19)) return true;
    return false;
  }

  private boolean jj_3R_56() {
    if (jj_scan_token(LET)) return true;
    return false;
  }

  private boolean jj_3R_55() {
    if (jj_scan_token(NUM)) return true;
    return false;
  }

  private boolean jj_3R_49() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_61()) {
    jj_scanpos = xsp;
    if (jj_3R_62()) {
    jj_scanpos = xsp;
    if (jj_3R_63()) {
    jj_scanpos = xsp;
    if (jj_3R_64()) return true;
    }
    }
    }
    xsp = jj_scanpos;
    if (jj_3R_65()) jj_scanpos = xsp;
    xsp = jj_scanpos;
    if (jj_3R_66()) jj_scanpos = xsp;
    xsp = jj_scanpos;
    if (jj_3R_67()) jj_scanpos = xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(20)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_51() {
    if (jj_3R_49()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_46() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_55()) {
    jj_scanpos = xsp;
    if (jj_3R_56()) {
    jj_scanpos = xsp;
    if (jj_3R_57()) {
    jj_scanpos = xsp;
    if (jj_3R_58()) return true;
    }
    }
    }
    xsp = jj_scanpos;
    if (jj_3R_59()) jj_scanpos = xsp;
    xsp = jj_scanpos;
    if (jj_3R_60()) jj_scanpos = xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(20)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_48() {
    if (jj_3R_46()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_50() {
    if (jj_3R_49()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_38() {
    if (jj_scan_token(16)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_51()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_51()) { jj_scanpos = xsp; break; }
    }
    if (jj_scan_token(17)) return true;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_47() {
    if (jj_3R_46()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_33() {
    if (jj_scan_token(16)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_48()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_48()) { jj_scanpos = xsp; break; }
    }
    if (jj_scan_token(17)) return true;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_19() {
    if (jj_3R_27()) return true;
    return false;
  }

  private boolean jj_3R_37() {
    if (jj_scan_token(14)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_50()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_50()) { jj_scanpos = xsp; break; }
    }
    if (jj_scan_token(15)) return true;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_36() {
    if (jj_3R_49()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_32() {
    if (jj_scan_token(14)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_47()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_47()) { jj_scanpos = xsp; break; }
    }
    if (jj_scan_token(15)) return true;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_31() {
    if (jj_3R_46()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_25() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_36()) {
    jj_scanpos = xsp;
    if (jj_3R_37()) {
    jj_scanpos = xsp;
    if (jj_3R_38()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_16() {
    if (jj_3R_24()) return true;
    return false;
  }

  private boolean jj_3R_22() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_31()) {
    jj_scanpos = xsp;
    if (jj_3R_32()) {
    jj_scanpos = xsp;
    if (jj_3R_33()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_18() {
    if (jj_3R_26()) return true;
    return false;
  }

  private boolean jj_3R_87() {
    if (jj_3R_27()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_26() {
    if (jj_scan_token(9)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_25()) return true;
    if (jj_scan_token(13)) return true;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_25()) return true;
    if (jj_scan_token(11)) return true;
    return false;
  }

  private boolean jj_3R_88() {
    if (jj_scan_token(12)) return true;
    return false;
  }

  private boolean jj_3R_15() {
    if (jj_3R_23()) return true;
    return false;
  }

  private boolean jj_3R_23() {
    if (jj_scan_token(9)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_22()) return true;
    if (jj_scan_token(13)) return true;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    if (jj_3R_22()) return true;
    if (jj_scan_token(11)) return true;
    return false;
  }

  private boolean jj_3R_86() {
    if (jj_3R_26()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_88()) jj_scanpos = xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_75() {
    if (jj_3R_24()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(7)) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_85() {
    if (jj_3R_25()) return true;
    return false;
  }

  private boolean jj_3R_17() {
    if (jj_3R_25()) return true;
    return false;
  }

  private boolean jj_3_3() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_17()) {
    jj_scanpos = xsp;
    if (jj_3R_18()) {
    jj_scanpos = xsp;
    if (jj_3R_19()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_78() {
    if (jj_scan_token(12)) return true;
    return false;
  }

  /** Generated Token Manager. */
  public SiteswapParserTokenManager token_source;
  SimpleCharStream jj_input_stream;
  /** Current token. */
  public Token token;
  /** Next token. */
  public Token jj_nt;
  private int jj_ntk;
  private Token jj_scanpos, jj_lastpos;
  private int jj_la;
  private int jj_gen;
  final private int[] jj_la1 = new int[58];
  static private int[] jj_la1_0;
  static {
      jj_la1_init_0();
   }
   private static void jj_la1_init_0() {
      jj_la1_0 = new int[] {0x80,0x4ed4230,0x4ed4230,0x100,0x400,0x1000,0x80,0x80,0x6d4230,0x80,0x80,0x80,0x80,0x80,0xc0030,0x80,0x80,0x80,0xc0030,0x80,0xd4030,0xc0030,0x80000,0x40,0x100000,0x600000,0x800000,0x80,0x1000000,0x80,0x80,0x1000,0x80,0x80,0x6d4230,0x80,0x80,0x80,0x80,0x80,0xc0030,0x80,0x80,0x80,0xc0030,0x80,0xd4030,0xc0030,0x80000,0x10,0x40000,0x40,0x100000,0x600000,0x10,0x4000000,0x600040,0x600040,};
   }
  final private JJCalls[] jj_2_rtns = new JJCalls[3];
  private boolean jj_rescan = false;
  private int jj_gc = 0;

  /** Constructor with InputStream. */
  public SiteswapParser(java.io.InputStream stream) {
     this(stream, null);
  }
  /** Constructor with InputStream and supplied encoding */
  public SiteswapParser(java.io.InputStream stream, String encoding) {
    try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source = new SiteswapParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 58; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Reinitialise. */
  public void ReInit(java.io.InputStream stream) {
     ReInit(stream, null);
  }
  /** Reinitialise. */
  public void ReInit(java.io.InputStream stream, String encoding) {
    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 58; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Constructor. */
  public SiteswapParser(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new SiteswapParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 58; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Reinitialise. */
  public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 58; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Constructor with generated Token Manager. */
  public SiteswapParser(SiteswapParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 58; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Reinitialise. */
  public void ReInit(SiteswapParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 58; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      if (++jj_gc > 100) {
        jj_gc = 0;
        for (int i = 0; i < jj_2_rtns.length; i++) {
          JJCalls c = jj_2_rtns[i];
          while (c != null) {
            if (c.gen < jj_gen) c.first = null;
            c = c.next;
          }
        }
      }
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  static private final class LookaheadSuccess extends java.lang.Error { }
  final private LookaheadSuccess jj_ls = new LookaheadSuccess();
  private boolean jj_scan_token(int kind) {
    if (jj_scanpos == jj_lastpos) {
      jj_la--;
      if (jj_scanpos.next == null) {
        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
      } else {
        jj_lastpos = jj_scanpos = jj_scanpos.next;
      }
    } else {
      jj_scanpos = jj_scanpos.next;
    }
    if (jj_rescan) {
      int i = 0; Token tok = token;
      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
      if (tok != null) jj_add_error_token(kind, i);
    }
    if (jj_scanpos.kind != kind) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
    return false;
  }


/** Get the next Token. */
  final public Token getNextToken() {
    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  }

/** Get the specific Token. */
  final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  private int jj_ntk() {
    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  }

  private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
  private int[] jj_expentry;
  private int jj_kind = -1;
  private int[] jj_lasttokens = new int[100];
  private int jj_endpos;

  private void jj_add_error_token(int kind, int pos) {
    if (pos >= 100) return;
    if (pos == jj_endpos + 1) {
      jj_lasttokens[jj_endpos++] = kind;
    } else if (jj_endpos != 0) {
      jj_expentry = new int[jj_endpos];
      for (int i = 0; i < jj_endpos; i++) {
        jj_expentry[i] = jj_lasttokens[i];
      }
      jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
        int[] oldentry = (int[])(it.next());
        if (oldentry.length == jj_expentry.length) {
          for (int i = 0; i < jj_expentry.length; i++) {
            if (oldentry[i] != jj_expentry[i]) {
              continue jj_entries_loop;
            }
          }
          jj_expentries.add(jj_expentry);
          break jj_entries_loop;
        }
      }
      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
    }
  }

  /** Generate ParseException. */
  public ParseException generateParseException() {
    jj_expentries.clear();
    boolean[] la1tokens = new boolean[27];
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 58; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 27; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.add(jj_expentry);
      }
    }
    jj_endpos = 0;
    jj_rescan_token();
    jj_add_error_token(0, 0);
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = jj_expentries.get(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  /** Enable tracing. */
  final public void enable_tracing() {
  }

  /** Disable tracing. */
  final public void disable_tracing() {
  }

  private void jj_rescan_token() {
    jj_rescan = true;
    for (int i = 0; i < 3; i++) {
    try {
      JJCalls p = jj_2_rtns[i];
      do {
        if (p.gen > jj_gen) {
          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
          switch (i) {
            case 0: jj_3_1(); break;
            case 1: jj_3_2(); break;
            case 2: jj_3_3(); break;
          }
        }
        p = p.next;
      } while (p != null);
      } catch(LookaheadSuccess ls) { }
    }
    jj_rescan = false;
  }

  private void jj_save(int index, int xla) {
    JJCalls p = jj_2_rtns[index];
    while (p.gen > jj_gen) {
      if (p.next == null) { p = p.next = new JJCalls(); break; }
      p = p.next;
    }
    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
  }

  static final class JJCalls {
    int gen;
    Token first;
    int arg;
    JJCalls next;
  }

}
