}
*/
Token JudgeKeyToken(String IDString) throws Exception { }
public Token GetToken() throws Exception // in order to make it visible,we define it public {
Token token; int Char; char ch;
token = new Token(); // 初始化为SEMICO EmptyTokenString(); /*
* System.out.print(\ * System.out.println(\int loop;
for (loop = 0; loop < tokentab.TokenTab.length; loop++) // 需要进行初始化tokentab { }
Token errortoken; errortoken = new Token(); // 初始化为SEMICO。
errortoken.type = Token_Type.ERRTOKEN; return errortoken;
// System.out.println(tokentab.TokenTab[loop].lexeme); // ???
// System.out.println(tokentab.TokenTab[loop].lexeme.length()); if (IDString.contentEquals(tokentab.TokenTab[loop].lexeme)) // 如此判等
// 判断两个StringBuffer是不是相同 { }
/*
* System.out.print(loop); System.out.println(\ */
return tokentab.TokenTab[loop];
* System.out.print(token.lexeme); System.out.println(token.value); * System.out.println(\ */
token.lexeme = TokenBuffer; // 貌似这是错的~~,有点早了 // 如此赋值~~ for (;;) { }
// System.out.print(\// System.out.println((char)Char); AddCharTokenString((char) Char); if (isLetter((char) Char))
// int char之间的转换需要测试?? {
for (;;) {
Char = GetChar(); Char = GetChar();
// System.out.print(\// System.out.println(Char); // System.out.println((char)Char); if (Char == -1) {
token.type = Token_Type.NONTOKEN; return token; ch = (char) Char;
} else if (Char == 13)
// in unicode,huiche is\ // in unicode,huanhang is\ // if is true,then next char { }
if (!isspace((char) Char)) { }
// System.out.println(\break; LineNo++; // Char = Getchar();
// System.out.println(\// continue;
}
if (isalnum((char) Char)) }
AddCharTokenString((char) Char); // System.out.print((char)Char); // System.out.println(\break; else {
BackChar((char) Char);
// System.out.println(\/*
* int ch; ch = pr.read(); System.out.print((char)ch); * System.out.println(\ */ /*
* System.out.print(TokenBuffer.toString()); * System.out.println(\ */
token = JudgeKeyToken(TokenBuffer.toString()); token.lexeme = TokenBuffer; return token;
} else if (isDigit((char) Char)) {
for (;;) { }
if ((char) Char == '.') {
AddCharTokenString((char) Char); for (;;) { }
Char = GetChar(); if (isDigit((char) Char)) else
break;
AddCharTokenString((char) Char);
Char = GetChar(); if (isDigit((char) Char)) else
break;
AddCharTokenString((char) Char);
}// end of if((char)Char == '.')
BackChar((char) Char);
token.type = Token_Type.CONST_ID; token.lexeme = TokenBuffer;
token.value = Double.valueOf(TokenBuffer.toString()); // 如此实现atof的功能 return token; switch ((char) Char) { case ';':
token.type = Token_Type.SEMICO; break;
token.type = Token_Type.L_BRACKET; break;
token.type = Token_Type.R_BRACKET; break;
token.type = Token_Type.COMMA; break;
token.type = Token_Type.PLUS; break;
Char = GetChar(); if (Char == '-') { }
Char = GetChar(); if (Char == '/') {
while (Char != '\\n' && Char != -1)
Char = GetChar(); BackChar((char) Char); return GetToken(); BackChar((char) Char);
while (Char != '\\n' && Char != -1)
Char = GetChar(); BackChar((char) Char); return GetToken(); BackChar((char) Char);
token.type = Token_Type.MINUS; break;
} else {
case '(':
case ')':
case ',':
case '+':
case '-':
} else {
case '/':
} else {
}
}
token.type = Token_Type.DIV; break;
case '*':
Char = GetChar(); if ((char) Char == '*') { }
token.type = Token_Type.ERRTOKEN; break;
token.type = Token_Type.POWER; break;
BackChar((char) Char); token.type = Token_Type.MUL; break;
} else {
default:
}// end of switch((char)Char)
}// end of else return token;
boolean isLetter(char ch) { }
boolean isDigit(char ch) { }
boolean isalnum(char ch) { }
boolean isspace(char Char)
if (isLetter(ch) || isDigit(ch)) else
return false; return true; if (ch >= '0' && ch <= '9') else
return false; return true;
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '_')) else
return false; return true;