/* Generated By:JavaCC: Do not edit this line. EC.java */
package gnu.jel.generated;

import gnu.jel.Optimizer;
import gnu.jel.Library;
import gnu.jel.ExpressionImage;
import gnu.jel.CompilationException;
import java.io.StringReader;
import gnu.jel.debug.Debug;

public class EC implements ECConstants {

  final public void expression(Optimizer optimizer,Class resultType) throws ParseException, CompilationException {
 Token x;
    conditional(optimizer);
    x = jj_consume_token(0);
      try{
        if (resultType!=null) optimizer.convert(resultType,true);
        optimizer.finish();
       } catch (IllegalStateException e) {
         {if (true) throw new CompilationException(x,e.getMessage());}
       };
  }

  final public void conditional(Optimizer optimizer) throws ParseException, CompilationException {
    lor(optimizer);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 38:
      jj_consume_token(38);
    try{
      optimizer.conditional_true();
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(token,e.getMessage());}
    };
      conditional(optimizer);
      jj_consume_token(39);
    optimizer.conditional_false();
      conditional(optimizer);
    try{
      optimizer.conditional_end();
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(token,e.getMessage());}
    };
      break;
    default:
      jj_la1[0] = jj_gen;
      ;
    }
  }

  final public void lor(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    land(optimizer);
    label_1:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LOR:
        ;
        break;
      default:
        jj_la1[1] = jj_gen;
        break label_1;
      }
      x = jj_consume_token(LOR);
                             optimizer.binaryOP_param();
      land(optimizer);
    try {
      optimizer.binaryOP(ExpressionImage.LOG_OR,true);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void land(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    bor(optimizer);
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LAND:
        ;
        break;
      default:
        jj_la1[2] = jj_gen;
        break label_2;
      }
      x = jj_consume_token(LAND);
                             optimizer.binaryOP_param();
      bor(optimizer);
    try {
      optimizer.binaryOP(ExpressionImage.LOG_AN,true);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void bor(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    bxor(optimizer);
    label_3:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OR:
        ;
        break;
      default:
        jj_la1[3] = jj_gen;
        break label_3;
      }
      x = jj_consume_token(OR);
                            optimizer.binaryOP_param();
      bxor(optimizer);
    try {
      optimizer.binaryOP(ExpressionImage.BI_OR,false);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void bxor(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    band(optimizer);
    label_4:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case XOR:
        ;
        break;
      default:
        jj_la1[4] = jj_gen;
        break label_4;
      }
      x = jj_consume_token(XOR);
                             optimizer.binaryOP_param();
      band(optimizer);
    try {
      optimizer.binaryOP(ExpressionImage.BI_XO,false);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void band(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    equality(optimizer);
    label_5:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AND:
        ;
        break;
      default:
        jj_la1[5] = jj_gen;
        break label_5;
      }
      x = jj_consume_token(AND);
                                 optimizer.binaryOP_param();
      equality(optimizer);
    try {
      optimizer.binaryOP(ExpressionImage.BI_AN,false);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void equality(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    relation(optimizer);
    label_6:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case EQ:
      case NE:
        ;
        break;
      default:
        jj_la1[6] = jj_gen;
        break label_6;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case EQ:
        x = jj_consume_token(EQ);
        break;
      case NE:
        x = jj_consume_token(NE);
        break;
      default:
        jj_la1[7] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                                         optimizer.binaryOP_param();
      relation(optimizer);
    try {
      int op=ExpressionImage.BI_EQ;
      if (x.kind==NE) op=op=ExpressionImage.BI_NE;
      optimizer.binaryOP(op,false);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void relation(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    shift(optimizer);
    label_7:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LT:
      case GE:
      case GT:
      case LE:
        ;
        break;
      default:
        jj_la1[8] = jj_gen;
        break label_7;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LT:
        x = jj_consume_token(LT);
        break;
      case GE:
        x = jj_consume_token(GE);
        break;
      case GT:
        x = jj_consume_token(GT);
        break;
      case LE:
        x = jj_consume_token(LE);
        break;
      default:
        jj_la1[9] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                      optimizer.binaryOP_param();
      shift(optimizer);
    try {
      int op=999;
      switch(x.kind) {
      case LT: op=ExpressionImage.BI_LT; break;
      case GE: op=ExpressionImage.BI_GE; break;
      case GT: op=ExpressionImage.BI_GT; break;
      case LE: op=ExpressionImage.BI_LE; break;
      default:
      };

      optimizer.binaryOP(op,false);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void shift(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    sum(optimizer);
    label_8:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LS:
      case RS:
      case RUS:
        ;
        break;
      default:
        jj_la1[10] = jj_gen;
        break label_8;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LS:
        x = jj_consume_token(LS);
        break;
      case RS:
        x = jj_consume_token(RS);
        break;
      case RUS:
        x = jj_consume_token(RUS);
        break;
      default:
        jj_la1[11] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                    optimizer.binaryOP_param();
      sum(optimizer);
    try {
      int op=999;
      switch(x.kind) {
      case LS : op=ExpressionImage.BI_LS; break;
      case RS : op=ExpressionImage.BI_RSS; break;
      case RUS: op=ExpressionImage.BI_RUS; break;
      default:
      };
      optimizer.binaryOP(op,false);
    } catch (IllegalStateException e) {
      {if (true) throw new CompilationException(x,e.getMessage());}
    };
    }
  }

  final public void sum(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    term(optimizer);
    label_9:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case PLUS:
      case MINUS:
        ;
        break;
      default:
        jj_la1[12] = jj_gen;
        break label_9;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case PLUS:
        x = jj_consume_token(PLUS);
        break;
      case MINUS:
        x = jj_consume_token(MINUS);
        break;
      default:
        jj_la1[13] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                             optimizer.binaryOP_param();
      term(optimizer);
       try {
         int op=ExpressionImage.BI_MI;
         if (x.kind==PLUS) op=ExpressionImage.BI_PL;
         optimizer.binaryOP(op,false);
       } catch (IllegalStateException e) {
         {if (true) throw new CompilationException(x,e.getMessage());}
       };
    }
  }

  final public void term(Optimizer optimizer) throws ParseException, CompilationException {
 Token x;
    unary(optimizer);
    label_10:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case MULTIPLY:
      case DIVIDE:
      case REMAINDER:
        ;
        break;
      default:
        jj_la1[14] = jj_gen;
        break label_10;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case MULTIPLY:
        x = jj_consume_token(MULTIPLY);
        break;
      case DIVIDE:
        x = jj_consume_token(DIVIDE);
        break;
      case REMAINDER:
        x = jj_consume_token(REMAINDER);
        break;
      default:
        jj_la1[15] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
     optimizer.binaryOP_param();
      unary(optimizer);
      try {
        int op=ExpressionImage.BI_MU;
        if (x.kind==DIVIDE) op=ExpressionImage.BI_DI;
        if (x.kind==REMAINDER) op=ExpressionImage.BI_RE;
        optimizer.binaryOP(op,false);
      } catch (IllegalStateException e) {
        {if (true) throw new CompilationException(x,e.getMessage());}
      };
    }
  }

  final public void unary(Optimizer optimizer) throws ParseException, CompilationException {
  Token x;
  Token type_to;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case MINUS:
      x = jj_consume_token(MINUS);
      element(optimizer);
      try {
        optimizer.unary(ExpressionImage.UN_NE);
      } catch (IllegalStateException e) {
        {if (true) throw new CompilationException(x,e.getMessage());}
      };
      break;
    case BWCOMPL:
      x = jj_consume_token(BWCOMPL);
      element(optimizer);
      try {
        optimizer.unary(ExpressionImage.UN_NO);
      } catch (IllegalStateException e) {
        {if (true) throw new CompilationException(x,e.getMessage());}
      };
      break;
    case LOGCOMPL:
      x = jj_consume_token(LOGCOMPL);
      optimizer.logical_not_start();
      element(optimizer);
      try {
        optimizer.logical_not();
      } catch (IllegalStateException e) {
        {if (true) throw new CompilationException(x,e.getMessage());}
      };
      break;
    default:
      jj_la1[16] = jj_gen;
      if (jj_2_1(3)) {
        jj_consume_token(40);
        type_to = jj_consume_token(ID);
        jj_consume_token(41);
        element(optimizer);
      Class tc=null;
      for(int i=0;(i<ExpressionImage.primitiveTypeNames.length) && (tc==null);
          i++)
        if (type_to.image.equals(ExpressionImage.primitiveTypeNames[i]))
          tc=ExpressionImage.primitiveTypes[i];

      if (tc==null)
        {if (true) throw new CompilationException(type_to,"The string \""+type_to.image+
                                       "\" is not a valid primitive type.");}

      try {
        optimizer.convert(tc);
      } catch (IllegalStateException e) {
        {if (true) throw new CompilationException(type_to,e.getMessage());}
      };
      } else {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case FALSE:
        case TRUE:
        case INTEGER_LITERAL:
        case FLOATING_POINT_LITERAL:
        case CHARACTER_LITERAL:
        case STRING_LITERAL:
        case ID:
        case 40:
          element(optimizer);
          break;
        default:
          jj_la1[17] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
    }
  }

  final public void element(Optimizer optimizer) throws ParseException, CompilationException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER_LITERAL:
    case FLOATING_POINT_LITERAL:
    case CHARACTER_LITERAL:
    case STRING_LITERAL:
      literal(optimizer);
      break;
    case TRUE:
      jj_consume_token(TRUE);
              optimizer.load(true);
      break;
    case FALSE:
      jj_consume_token(FALSE);
              optimizer.load(false);
      break;
    case ID:
      function(optimizer);
      break;
    case 40:
      jj_consume_token(40);
      conditional(optimizer);
      jj_consume_token(41);
      break;
    default:
      jj_la1[18] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void function(Optimizer optimizer) throws ParseException, CompilationException {
  Token id;
    id = jj_consume_token(ID);
             optimizer.function_start();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 40:
      jj_consume_token(40);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case MINUS:
      case BWCOMPL:
      case LOGCOMPL:
      case FALSE:
      case TRUE:
      case INTEGER_LITERAL:
      case FLOATING_POINT_LITERAL:
      case CHARACTER_LITERAL:
      case STRING_LITERAL:
      case ID:
      case 40:
        conditional(optimizer);
                              optimizer.function_param();
        label_11:
        while (true) {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case 42:
            ;
            break;
          default:
            jj_la1[19] = jj_gen;
            break label_11;
          }
          jj_consume_token(42);
          conditional(optimizer);
                                           optimizer.function_param();
        }
        break;
      default:
        jj_la1[20] = jj_gen;
        ;
      }
      jj_consume_token(41);
      break;
    default:
      jj_la1[21] = jj_gen;
      ;
    }
       try {
         optimizer.function_call(id.image);
       } catch (IllegalStateException e) {
         {if (true) throw new CompilationException(id,e.getMessage());}
       };
  }

  final public void literal(Optimizer optimizer) throws ParseException, CompilationException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER_LITERAL:
      jj_consume_token(INTEGER_LITERAL);
                     {
    String svalue=token.image.toUpperCase();
    long value=0;
    boolean makelong=svalue.endsWith("L");
    if (makelong) svalue=svalue.substring(0,svalue.length()-1);

    try {
      if ( svalue.startsWith("0x") || svalue.startsWith("0X") ) {
        // Hexadecimal number
        svalue=svalue.substring(2);
        value=Long.parseLong(svalue,16);
      } else if (token.image.startsWith("0")) {
        // Octal number
        value=Long.parseLong(svalue,8);
      } else {
        // Decimal number
        value=Long.parseLong(svalue,10);
      };
    } catch (NumberFormatException e) {
      {if (true) throw new CompilationException(token,"Number \""+token.image+
                                     "\" is too large, it does not fit even "+
                                     "into 64 bit long.");} // Overflow ?
    };

    if (!makelong) { // Check ranges
      if (value<=127) optimizer.load((byte)value);
      else if (value<=32767) optimizer.load((short)value);
      else if (value<=2147483647) optimizer.load((int)value);
      else
        {if (true) throw
          new CompilationException(token,"Integer number \""+token.image+
                                   "\" is too large for type 'int'. Be sure"+
                                   " to add 'L' suffix to use 'long' type.");}
    } else {
      optimizer.load(value);
    };

  }
      break;
    case FLOATING_POINT_LITERAL:
      jj_consume_token(FLOATING_POINT_LITERAL);
                            {
  char lc=Character.toUpperCase(token.image.charAt(token.image.length()-1));
  boolean makeFloat = (lc=='F');
  String svalue=token.image;
  if ((lc=='D') || (lc=='F')) {
    svalue=svalue.substring(0,svalue.length()-1);
  };
  Double value=null;
  try {
    value=new Double(svalue);
  } catch (NumberFormatException e) {
    // Overflow ? Will produce infinity.
  };
  if (makeFloat)
    optimizer.load(value.floatValue());
  else
    optimizer.load(value.doubleValue());
  }
      break;
    case CHARACTER_LITERAL:
      jj_consume_token(CHARACTER_LITERAL);
                       {
  String sval=token.image.substring(1,token.image.length()-1);
  if (sval.length()==1)
    optimizer.load(sval.charAt(0));
  else{ // escape or number
    char ec=sval.charAt(1);
    try {
      switch (ec) {
      case 'n': ec='\n'; break;
      case 't': ec='\t'; break;
      case 'b': ec='\b'; break;
      case 'r': ec='\r'; break;
      case 'f': ec='\f'; break;
      case '\\': ec='\\'; break;
      case '\'': ec='\''; break;
      case '\"': ec='"'; break;
      default:
        ec=(char) Integer.parseInt(sval.substring(1),8);
      };
    } catch (NumberFormatException e) {/* Can't be */};
    optimizer.load(ec);
  };
  }
      break;
    case STRING_LITERAL:
      jj_consume_token(STRING_LITERAL);
                    {
  String sval=token.image.substring(1,token.image.length()-1);
  StringBuffer unescaped=new StringBuffer(sval.length());
  for(int i=0;i<sval.length();i++) {
    char ec=sval.charAt(i);
    if (ec=='\\') { // escape
      ec=sval.charAt(++i);
      switch (ec) {
      case 'n': ec='\n'; break;
      case 't': ec='\t'; break;
      case 'b': ec='\b'; break;
      case 'r': ec='\r'; break;
      case 'f': ec='\f'; break;
      case '\\': ec='\\'; break;
      case '\'': ec='\''; break;
      case '\"': ec='"'; break;
      default:
        int nval=0;
        while ((i<sval.length()) && ((ec=sval.charAt(i))>='0') && (ec<='7')) {
          nval=nval<<3+(ec-'0');
          i++;
        };
        i--;
        ec=(char)nval;
      };
    };
    unescaped.append(ec);
  };
  optimizer.load(unescaped.toString());
  }
      break;
    default:
      jj_la1[22] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final private boolean jj_2_1(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    boolean retval = !jj_3_1();
    jj_save(0, xla);
    return retval;
  }

  final private boolean jj_3_1() {
    if (jj_scan_token(40)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_scan_token(ID)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_scan_token(41)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  public ECTokenManager token_source;
  ASCII_CharStream jj_input_stream;
  public Token token, jj_nt;
  private int jj_ntk;
  private Token jj_scanpos, jj_lastpos;
  private int jj_la;
  public boolean lookingAhead = false;
  private boolean jj_semLA;
  private int jj_gen;
  final private int[] jj_la1 = new int[23];
  final private int[] jj_la1_0 = {0x0,0x4000,0x1000,0x2000,0x8000,0x800,0x30000,0x30000,0x3c0000,0x3c0000,0x1c00000,0x1c00000,0x30,0x30,0x700,0x700,0xe0,0x8e000000,0x8e000000,0x0,0x8e0000e0,0x0,0x88000000,};
  final private int[] jj_la1_1 = {0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10e,0x10e,0x400,0x10e,0x100,0x6,};
  final private JJCalls[] jj_2_rtns = new JJCalls[1];
  private boolean jj_rescan = false;
  private int jj_gc = 0;

  public EC(java.io.InputStream stream) {
    jj_input_stream = new ASCII_CharStream(stream, 1, 1);
    token_source = new ECTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 23; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public void ReInit(java.io.InputStream 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 < 23; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public EC(java.io.Reader stream) {
    jj_input_stream = new ASCII_CharStream(stream, 1, 1);
    token_source = new ECTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 23; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  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 < 23; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public EC(ECTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 23; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

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

  final 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();
  }

  final 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);
    }
    return (jj_scanpos.kind != kind);
  }

  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;
  }

  final public Token getToken(int index) {
    Token t = lookingAhead ? jj_scanpos : token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  final 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.Vector jj_expentries = new java.util.Vector();
  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];
      }
      boolean exists = false;
      for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) {
        int[] oldentry = (int[])(enum.nextElement());
        if (oldentry.length == jj_expentry.length) {
          exists = true;
          for (int i = 0; i < jj_expentry.length; i++) {
            if (oldentry[i] != jj_expentry[i]) {
              exists = false;
              break;
            }
          }
          if (exists) break;
        }
      }
      if (!exists) jj_expentries.addElement(jj_expentry);
      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
    }
  }

  final public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[43];
    for (int i = 0; i < 43; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 23; 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;
          }
          if ((jj_la1_1[i] & (1<<j)) != 0) {
            la1tokens[32+j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 43; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(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] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  final public void enable_tracing() {
  }

  final public void disable_tracing() {
  }

  final private void jj_rescan_token() {
    jj_rescan = true;
    for (int i = 0; i < 1; i++) {
      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;
          }
        }
        p = p.next;
      } while (p != null);
    }
    jj_rescan = false;
  }

  final 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;
  }

                  /* EC stands for ExpressionCompiler */
};
