int nextToken() throws IOException {
  byte[] ct=charTypes;
  int c;
  value=null;
  if (type == TYPE_NOTHING) {
    c=read();
    if (c >= 0) {
      type=c;
    }
  }
 else {
    c=peekChar;
    if (c < 0) {
      try {
        c=read();
        if (c >= 0) {
          type=c;
        }
      }
 catch (      EOFException e) {
        c=-1;
      }
    }
  }
  if (c < 0) {
    return type=TYPE_EOF;
  }
  int charType=c < 256 ? ct[c] : ALPHA;
  while ((charType & WHITESPACE) != 0) {
    if (c == '\r') {
      line++;
      c=read();
      if (c == '\n') {
        c=read();
      }
    }
 else {
      if (c == '\n') {
        line++;
      }
      c=read();
    }
    if (c < 0) {
      return type=TYPE_EOF;
    }
    charType=c < 256 ? ct[c] : ALPHA;
  }
  if ((charType & ALPHA) != 0) {
    initToken();
    append(c);
    int i=0;
    do {
      if (i >= chars.length) {
        char[] nb=new char[chars.length * 2];
        System.arraycopy(chars,0,nb,0,chars.length);
        chars=nb;
      }
      chars[i++]=(char)c;
      c=read();
      charType=c < 0 ? WHITESPACE : c < 256 ? ct[c] : ALPHA;
    }
 while ((charType & ALPHA) != 0);
    peekChar=c;
    value=String.copyValueOf(chars,0,i);
    return type=TYPE_WORD;
  }
  if ((charType & QUOTE) != 0) {
    initToken();
    append(c);
    type=c;
    int i=0;
    peekChar=read();
    while (peekChar >= 0 && peekChar != type && peekChar != '\n' && peekChar != '\r') {
      if (peekChar == '\\') {
        c=read();
        int first=c;
        if (c >= '0' && c <= '7') {
          c=c - '0';
          int c2=read();
          if ('0' <= c2 && c2 <= '7') {
            c=(c << 3) + (c2 - '0');
            c2=read();
            if ('0' <= c2 && c2 <= '7' && first <= '3') {
              c=(c << 3) + (c2 - '0');
              peekChar=read();
            }
 else {
              peekChar=c2;
            }
          }
 else {
            peekChar=c2;
          }
        }
 else {
switch (c) {
case 'b':
            c='\b';
          break;
case 'f':
        c='\f';
      break;
case 'n':
    c='\n';
  break;
case 'r':
c='\r';
break;
case 't':
c='\t';
break;
default :
}
peekChar=read();
}
}
 else {
c=peekChar;
peekChar=read();
}
if (i >= chars.length) {
char[] nb=new char[chars.length * 2];
System.arraycopy(chars,0,nb,0,chars.length);
chars=nb;
}
chars[i++]=(char)c;
}
if (peekChar == type) {
peekChar=read();
}
value=String.copyValueOf(chars,0,i);
return type;
}
if (c == '/') {
c=read();
if (c == '*') {
int prevChar=0;
while ((c=read()) != '/' || prevChar != '*') {
if (c == '\r') {
line++;
c=read();
if (c == '\n') {
c=read();
}
}
 else {
if (c == '\n') {
line++;
c=read();
}
}
if (c < 0) {
return type=TYPE_EOF;
}
prevChar=c;
}
peekChar=read();
return nextToken();
}
 else if (c == '/') {
while ((c=read()) != '\n' && c != '\r' && c >= 0) {
}
peekChar=c;
return nextToken();
}
 else {
peekChar=c;
return type='/';
}
}
peekChar=read();
return type=c;
}

int nextToken ( ) throws IOException { byte [ ] ct = charTypes ; int c ; value = null ; if ( type == TYPE_NOTHING ) { c = read ( ) ; if ( c >= 0 ) { type = c ; } } else { c = peekChar ; if ( c < 0 ) { try { c = read ( ) ; if ( c >= 0 ) { type = c ; } } catch ( EOFException e ) { c = - 1 ; } } } if ( c < 0 ) { return type = TYPE_EOF ; } int charType = c < 256 ? ct [ c ] : ALPHA ; while ( ( charType & WHITESPACE ) != 0 ) { if ( c == '\r' ) { line ++ ; c = read ( ) ; if ( c == '\n' ) { c = read ( ) ; } } else { if ( c == '\n' ) { line ++ ; } c = read ( ) ; } if ( c < 0 ) { return type = TYPE_EOF ; } charType = c < 256 ? ct [ c ] : ALPHA ; } if ( ( charType & ALPHA ) != 0 ) { initToken ( ) ; append ( c ) ; int i = 0 ; do { if ( i >= chars . length ) { char [ ] nb = new char [ chars . length * 2 ] ; System . arraycopy ( chars , 0 , nb , 0 , chars . length ) ; chars = nb ; } chars [ i ++ ] = ( char ) c ; c = read ( ) ; charType = c < 0 ? WHITESPACE : c < 256 ? ct [ c ] : ALPHA ; } while ( ( charType & ALPHA ) != 0 ) ; peekChar = c ; value = String . copyValueOf ( chars , 0 , i ) ; return type = TYPE_WORD ; } if ( ( charType & QUOTE ) != 0 ) { initToken ( ) ; append ( c ) ; type = c ; int i = 0 ; peekChar = read ( ) ; while ( peekChar >= 0 && peekChar != type && peekChar != '\n' && peekChar != '\r' ) { if ( peekChar == '\\' ) { c = read ( ) ; int first = c ; if ( c >= '0' && c <= '7' ) { c = c - '0' ; int c2 = read ( ) ; if ( '0' <= c2 && c2 <= '7' ) { c = ( c << 3 ) + ( c2 - '0' ) ; c2 = read ( ) ; if ( '0' <= c2 && c2 <= '7' && first <= '3' ) { c = ( c << 3 ) + ( c2 - '0' ) ; peekChar = read ( ) ; } else { peekChar = c2 ; } } else { peekChar = c2 ; } } else { switch ( c ) { case 'b' : c = '\b' ; break ; case 'f' : c = '\f' ; break ; case 'n' : c = '\n' ; break ; case 'r' : c = '\r' ; break ; case 't' : c = '\t' ; break ; default : } peekChar = read ( ) ; } } else { c = peekChar ; peekChar = read ( ) ; } if ( i >= chars . length ) { char [ ] nb = new char [ chars . length * 2 ] ; System . arraycopy ( chars , 0 , nb , 0 , chars . length ) ; chars = nb ; } chars [ i ++ ] = ( char ) c ; } if ( peekChar == type ) { peekChar = read ( ) ; } value = String . copyValueOf ( chars , 0 , i ) ; return type ; } if ( c == '/' ) { c = read ( ) ; if ( c == '*' ) { int prevChar = 0 ; while ( ( c = read ( ) ) != '/' || prevChar != '*' ) { if ( c == '\r' ) { line ++ ; c = read ( ) ; if ( c == '\n' ) { c = read ( ) ; } } else { if ( c == '\n' ) { line ++ ; c = read ( ) ; } } if ( c < 0 ) { return type = TYPE_EOF ; } prevChar = c ; } peekChar = read ( ) ; return nextToken ( ) ; } else if ( c == '/' ) { while ( ( c = read ( ) ) != '\n' && c != '\r' && c >= 0 ) { } peekChar = c ; return nextToken ( ) ; } else { peekChar = c ; return type = '/' ; } } peekChar = read ( ) ; return type = c ; }
read the next token and get the token type .
