Ejemplo n.º 1
0
 public void nextValidToken() throws IOException {
   int level = 0;
   String n1 = null;
   String n2 = null;
   int ptr = 0;
   while (nextToken()) {
     if (type == TK_COMMENT) continue;
     switch (level) {
       case 0:
         {
           if (type != TK_NUMBER) return;
           ptr = file.getFilePointer();
           n1 = stringValue;
           ++level;
           break;
         }
       case 1:
         {
           if (type != TK_NUMBER) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           n2 = stringValue;
           ++level;
           break;
         }
       default:
         {
           if (type != TK_OTHER || !stringValue.equals("R")) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           type = TK_REF;
           reference = Integer.valueOf(n1).intValue();
           generation = Integer.valueOf(n2).intValue();
           return;
         }
     }
   }
   throwError("Unexpected end of file");
 }
Ejemplo n.º 2
0
 public void throwError(String error) throws IOException {
   throw new IOException(error + " at file pointer " + file.getFilePointer());
 }
Ejemplo n.º 3
0
 public int getFilePointer() throws IOException {
   return file.getFilePointer();
 }