/** Returns the next lexical token in the document. */ public int nextToken() { int c; fStartToken = fPos; while (true) { switch (c = read()) { case EOF: return EOF; case '/': // comment c = read(); if (c == '/') { while (true) { c = read(); if ((c == EOF) || (c == EOL)) { unread(c); return COMMENT; } } } else { unread(c); } return OTHER; case '\'': // char const character: for (; ; ) { c = read(); switch (c) { case '\'': return STRING; case EOF: unread(c); return STRING; case '\\': c = read(); break; } } case '"': // string string: for (; ; ) { c = read(); switch (c) { case '"': return STRING; case EOF: unread(c); return STRING; case '\\': c = read(); break; } } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': do { c = read(); } while (Character.isDigit((char) c)); unread(c); return NUMBER; default: if (Character.isWhitespace((char) c)) { do { c = read(); } while (Character.isWhitespace((char) c)); unread(c); return WHITE; } if (Character.isJavaIdentifierStart((char) c)) { fBuffer.setLength(0); do { fBuffer.append((char) c); c = read(); } while (Character.isJavaIdentifierPart((char) c)); unread(c); Integer i = (Integer) fgKeys.get(fBuffer.toString()); if (i != null) return i.intValue(); return WORD; } return OTHER; } } }