我在这段代码中遇到了很难匹配大括号的时间。它始终指示没有“if”错误的“else”,但不确定语法应如何阅读。如果任何人都可以帮助它,将不胜感激。这里是代码:匹配卷曲括号
private void compileFactor() {
boolean its_a_variable = theInfo.isVar();
if (isIdent(theToken)) {
String ident = theToken;
theToken = t.token(); // handles var and const cases!
IdentInfo theInfo = symTable.lookup(ident);
}
boolean its_a_variable = theInfo.isVar();
int theAddr = theInfo.getAddr();
boolean isGlobal = theInfo.getIsGlobal();
int constValue = theInfo.getValue();
if (its_a_variable) { // pld12: CHANGE THIS!!
int theAddr = theInfo.getAddr();
boolean isGlobal = theInfo.getIsGlobal();
if (theAddr == -1) t.error("undeclared identifier used in expr: "+ident);
if (isGlobal) cs.emit(Machine.LOAD, theAddr);
else cs.emit(Machine.LOADF, theAddr);
} else {
int constValue = theInfo.getValue();
if (constValue = null) t.error("undeclared identifier used in expr: "+ident);
else {
cs.emitLOADI(theNumber);
}
else if (isNumber(theToken)) {
int theNumber = new Integer(theToken).intValue();
cs.emitLOADINT(theNumber);
theToken = t.token();
}
else if (equals(theToken, "(")) { // nothing to do to generate code!
accept("(");
compileExpr();
accept(")");
}
}
为什么你不能使用文本编辑器,简单的语法的理解来跟踪所有相应的打开和关闭括号? – artdanil 2009-12-07 02:21:11
请说这是哪种语言。 – 2009-12-07 04:14:24