我有一个方法,产生一个int期望,但发现布尔错误,但当我切换到一个布尔值它说相同的错误,但反向int和布尔值。这里是我的代码:INT和布尔错误
private void compileDeclaration(boolean isGlobal) {
if (equals(theToken, "int")) {
accept("int");
String ident = theToken;
if (!isIdent(theToken)) t.error("expected identifier, got " + theToken);
else if (isGlobal){
symTable.allocVar(ident, isGlobal);
}
if (!isGlobal) cs.emit(Machine.ALLOC, symTable.stackFrameSize());
//dprint("declaring int " + ident);
theToken = t.token();
accept (";");
} else if (equals (theToken, "final")) {
accept("final");
accept("int");
String ident = theToken;
if (!isIdent(theToken)) t.error("expected identifier, got " + theToken);
theToken = t.token();
accept("=");
int numvalue = new Integer(theToken).intValue();
if (!isNumber(theToken)) t.error("expected number, got " + theToken);
else if (numvalue = 0) { **//This is where it highlights my error**
symTable.allocConst(ident, numvalue);
}
任何帮助将不胜感激。
语言是什么呢? – ysth 2009-12-07 03:07:57
不错,你展示的代码,你只需要显示错误信息,这将更容易发现。我认为菲利普·甘有正确的答案,你应该让他接受。 – OscarRyz 2009-12-07 03:30:34