exprType msg = arity == 2 ? ((exprType) stack.popNode()) : null;
test = (exprType) stack.popNode();
return new Assert(test, msg);
case JJTBEGIN_TRY_STMT:
//we do that just to get the specials
return new TryExcept(null, null, null);
case JJTTRYELSE_STMT:
orelseSuite = popSuiteAndSuiteType();
return orelseSuite;
case JJTTRYFINALLY_OUTER_STMT:
orelseSuite = popSuiteAndSuiteType();
return new TryFinally(null, orelseSuite); //it does not have a body at this time... it will be filled with the inner try..except
case JJTTRY_STMT:
TryFinally outer = null;
if (stack.peekNode() instanceof TryFinally) {
outer = (TryFinally) stack.popNode();
arity--;
}
orelseSuite = null;
if (stack.peekNode() instanceof suiteType) {
orelseSuite = (suiteType) stack.popNode();
arity--;
}
l = arity;
excepthandlerType[] handlers = new excepthandlerType[l];
for (int i = l - 1; i >= 0; i--) {
handlers[i] = (excepthandlerType) stack.popNode();
}
suite = (Suite) stack.popNode();
TryExcept tryExc = (TryExcept) stack.popNode();
if (outer != null) {
outer.beginLine = tryExc.beginLine;
}
tryExc.body = suite.body;
tryExc.handlers = handlers;
tryExc.orelse = orelseSuite;
addSpecials(suite, tryExc);
if (outer == null) {
return tryExc;
} else {
if (outer.body != null) {
throw new RuntimeException("Error. Expecting null body to be filled on try..except..finally");
}
outer.body = new stmtType[] { tryExc };
return outer;
}
case JJTBEGIN_TRY_ELSE_STMT:
//we do that just to get the specials
return new Suite(null);
case JJTBEGIN_EXCEPT_CLAUSE:
return new excepthandlerType(null, null, null);
case JJTEXCEPT_CLAUSE:
suite = (Suite) stack.popNode();
body = suite.body;
exprType excname = arity == 4 ? ((exprType) stack.popNode()) : null;
if (excname != null) {
ctx.setStore(excname);
}
type = arity >= 3 ? ((exprType) stack.popNode()) : null;
excepthandlerType handler = (excepthandlerType) stack.popNode();
handler.type = type;
handler.name = excname;
handler.body = body;
addSpecials(suite, handler);
return handler;
case JJTBEGIN_FINALLY_STMT:
//we do that just to get the specials
return new Suite(null);
case JJTTRYFINALLY_STMT:
suiteType finalBody = popSuiteAndSuiteType();
body = popSuite();
//We have a try..except in the stack, but we will change it for a try..finally
//This is because we recognize a try..except in the 'try:' token, but actually end up with a try..finally
TryExcept tryExcept = (TryExcept) stack.popNode();
TryFinally tryFinally = new TryFinally(body, finalBody);
tryFinally.beginLine = tryExcept.beginLine;
tryFinally.beginColumn = tryExcept.beginColumn;
addSpecialsAndClearOriginal(tryExcept, tryFinally);
return tryFinally;