private Token scanToken(){
  Token token=_token;
  if (token != null) {
    _token=null;
    return token;
  }
  int sign=1;
  int ch;
  for (ch=read(); Character.isWhitespace((char)ch); ch=read()) {
  }
switch (ch) {
case -1:
    return Token.EOF;
case '(':
  return Token.LPAREN;
case ')':
return Token.RPAREN;
case ',':
return Token.COMMA;
case '*':
return Token.STAR;
case '-':
return Token.MINUS;
case '+':
return Token.PLUS;
case '/':
return Token.DIV;
case '%':
return Token.MOD;
case '.':
return Token.DOT;
case '?':
return Token.QUESTION_MARK;
case '=':
return Token.EQ;
case '<':
if ((ch=read()) == '=') return Token.LE;
 else if (ch == '>') return Token.NE;
 else {
unread(ch);
return Token.LT;
}
case '>':
if ((ch=read()) == '=') return Token.GE;
 else {
unread(ch);
return Token.GT;
}
}
if (Character.isJavaIdentifierStart((char)ch) || ch == ':') {
CharBuffer cb=_cb;
cb.clear();
for (; ch > 0 && isIdentifierPart((char)ch); ch=read()) {
cb.append((char)ch);
}
unread(ch);
_lexeme=cb.toString();
String lower=_lexeme.toLowerCase(Locale.ENGLISH);
token=_reserved.get(lower);
if (token != null) return token;
 else return Token.IDENTIFIER;
}
 else if (ch >= '0' && ch <= '9') {
CharBuffer cb=_cb;
cb.clear();
Token type=Token.INTEGER;
if (sign < 0) cb.append('-');
for (; ch >= '0' && ch <= '9'; ch=read()) cb.append((char)ch);
if (ch == '.') {
type=Token.DOUBLE;
cb.append('.');
for (ch=read(); ch >= '0' && ch <= '9'; ch=read()) cb.append((char)ch);
}
if (ch == 'e' || ch == 'E') {
type=Token.DOUBLE;
cb.append('e');
if ((ch=read()) == '+' || ch == '-') {
cb.append((char)ch);
ch=read();
}
if (!(ch >= '0' && ch <= '9')) throw error(L.l("exponent needs digits at {0}",charName(ch)));
for (; ch >= '0' && ch <= '9'; ch=read()) cb.append((char)ch);
}
if (ch == 'F' || ch == 'D') type=Token.DOUBLE;
 else if (ch == 'L') {
type=Token.LONG;
}
 else unread(ch);
_lexeme=cb.toString();
return type;
}
 else if (ch == '\'') {
CharBuffer cb=_cb;
cb.clear();
for (ch=read(); ch >= 0; ch=read()) {
if (ch == '\'') {
if ((ch=read()) == '\'') cb.append('\'');
 else {
unread(ch);
break;
}
}
 else if (ch == '\\') {
ch=read();
if (ch >= 0) cb.append(ch);
}
 else cb.append((char)ch);
}
_lexeme=cb.toString();
return Token.STRING;
}
 else if (ch == '#') {
while ((ch=read()) >= 0 && ch != '\n' && ch != '\r') {
}
return scanToken();
}
throw error(L.l("unexpected char at {0} ({1})","" + (char)ch,String.valueOf(ch)));
}

private Token scanToken ( ) { Token token = _token ; if ( token != null ) { _token = null ; return token ; } int sign = 1 ; int ch ; for ( ch = read ( ) ; Character . isWhitespace ( ( char ) ch ) ; ch = read ( ) ) { } switch ( ch ) { case - 1 : return Token . EOF ; case '(' : return Token . LPAREN ; case ')' : return Token . RPAREN ; case ',' : return Token . COMMA ; case '*' : return Token . STAR ; case '-' : return Token . MINUS ; case '+' : return Token . PLUS ; case '/' : return Token . DIV ; case '%' : return Token . MOD ; case '.' : return Token . DOT ; case '?' : return Token . QUESTION_MARK ; case '=' : return Token . EQ ; case '<' : if ( ( ch = read ( ) ) == '=' ) return Token . LE ; else if ( ch == '>' ) return Token . NE ; else { unread ( ch ) ; return Token . LT ; } case '>' : if ( ( ch = read ( ) ) == '=' ) return Token . GE ; else { unread ( ch ) ; return Token . GT ; } } if ( Character . isJavaIdentifierStart ( ( char ) ch ) || ch == ':' ) { CharBuffer cb = _cb ; cb . clear ( ) ; for ( ; ch > 0 && isIdentifierPart ( ( char ) ch ) ; ch = read ( ) ) { cb . append ( ( char ) ch ) ; } unread ( ch ) ; _lexeme = cb . toString ( ) ; String lower = _lexeme . toLowerCase ( Locale . ENGLISH ) ; token = _reserved . get ( lower ) ; if ( token != null ) return token ; else return Token . IDENTIFIER ; } else if ( ch >= '0' && ch <= '9' ) { CharBuffer cb = _cb ; cb . clear ( ) ; Token type = Token . INTEGER ; if ( sign < 0 ) cb . append ( '-' ) ; for ( ; ch >= '0' && ch <= '9' ; ch = read ( ) ) cb . append ( ( char ) ch ) ; if ( ch == '.' ) { type = Token . DOUBLE ; cb . append ( '.' ) ; for ( ch = read ( ) ; ch >= '0' && ch <= '9' ; ch = read ( ) ) cb . append ( ( char ) ch ) ; } if ( ch == 'e' || ch == 'E' ) { type = Token . DOUBLE ; cb . append ( 'e' ) ; if ( ( ch = read ( ) ) == '+' || ch == '-' ) { cb . append ( ( char ) ch ) ; ch = read ( ) ; } if ( ! ( ch >= '0' && ch <= '9' ) ) throw error ( L . l ( "exponent needs digits at {0}" , charName ( ch ) ) ) ; for ( ; ch >= '0' && ch <= '9' ; ch = read ( ) ) cb . append ( ( char ) ch ) ; } if ( ch == 'F' || ch == 'D' ) type = Token . DOUBLE ; else if ( ch == 'L' ) { type = Token . LONG ; } else unread ( ch ) ; _lexeme = cb . toString ( ) ; return type ; } else if ( ch == '\'' ) { CharBuffer cb = _cb ; cb . clear ( ) ; for ( ch = read ( ) ; ch >= 0 ; ch = read ( ) ) { if ( ch == '\'' ) { if ( ( ch = read ( ) ) == '\'' ) cb . append ( '\'' ) ; else { unread ( ch ) ; break ; } } else if ( ch == '\\' ) { ch = read ( ) ; if ( ch >= 0 ) cb . append ( ch ) ; } else cb . append ( ( char ) ch ) ; } _lexeme = cb . toString ( ) ; return Token . STRING ; } else if ( ch == '#' ) { while ( ( ch = read ( ) ) >= 0 && ch != '\n' && ch != '\r' ) { } return scanToken ( ) ; } throw error ( L . l ( "unexpected char at {0} ({1})" , "" + ( char ) ch , String . valueOf ( ch ) ) ) ; }
scan the next token . if the lexeme is a string , its string representation is in " lexeme " .
