编译原理上机报告(7)

2019-08-03 11:33

}

*/

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;


编译原理上机报告(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:化工仪表实验指导书3[1].0

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: