I am having a difficult time matching up curly brackets in this code. It keeps indicating a "else" without an "if" error but not sure how the syntax should read. If anyone can help it would be most appreciated. Here is the code:
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(")");
}
}