www.pudn.com > ParseAna.rar > Error.java
/**
* this class handle the error problem
* @author:贺静
* @version :1.2
*/
import java.io.IOException;
public class Error {
public String getError(int errorCon) throws IOException {
String s = "";
switch (errorCon) {
// case -1 to -4 is the parse error
case -1:
s = " 程序必须以 'class' 开始 \n";
break;
case -2:
s = " 程序体必须以 '{' 开始 \n ";
break;
case -3:
s = " 'Class' 只能是程序开始标识符 \n";
break;
case -4:
s = " unwanted input: the program should already end \n";
break;
// case -30 to -35 is the lex error
case -30:
s = " 注释不匹配" + "\n";
break;
case -31:
s = " 标识符不能以 '_' 结束" + "\n";
break;
case -32:
s = "'" + "' 标识符不能以数字开头" + "\n";
break;
case -33:
s = "'" + "' 数字不能以 '.' 结束" + "\n";
break;
case -34:
s = " invalid input " + "\n";
break;
case -35:
s = " 数字的输入格式错误" + "\n";
break;
default:
break;
}
return s;
}
}