У меня есть метод, который генерирует и вызывает ошибку, которую ожидал int, но найденный логически, но когда я переключу его на логическое, он говорит ту же ошибку, но обращает int и boolean. Вот мой код:int и boolean error
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
Хорошо, что вы показываете код, вам просто нужно показать сообщение об ошибке, и это будет легче обнаружить. Я думаю, что у Филлипа Нгана есть правильный ответ, вы должны принять его как принято. – OscarRyz