use of org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken in project jphp by jphp-compiler.
the class TryCatchGenerator method processCatches.
protected void processCatches(TryStmtToken result, Token current, ListIterator<Token> iterator) {
List<CatchStmtToken> catches = result.getCatches();
do {
CatchStmtToken _catch = (CatchStmtToken) current;
processCatch(_catch, iterator);
catches.add(_catch);
if (!iterator.hasNext())
break;
current = iterator.next();
if (!(current instanceof CatchStmtToken)) {
if (current instanceof FinallyStmtToken) {
processFinally(result, current, iterator);
break;
}
iterator.previous();
break;
}
} while (true);
}
use of org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken in project jphp by jphp-compiler.
the class TryCatchGenerator method getToken.
@Override
public TryStmtToken getToken(Token current, ListIterator<Token> iterator) {
if (current instanceof TryStmtToken) {
TryStmtToken result = (TryStmtToken) current;
analyzer.addScope(false);
BodyStmtToken body = analyzer.generator(BodyGenerator.class).getToken(nextToken(iterator), iterator);
result.setBody(body);
Token next = nextToken(iterator);
result.setCatches(new ArrayList<CatchStmtToken>());
if (next instanceof CatchStmtToken) {
processCatches(result, next, iterator);
} else if (next instanceof FinallyStmtToken) {
analyzer.getScope().setLevelForGoto(true);
processFinally(result, next, iterator);
analyzer.getScope().setLevelForGoto(false);
} else
unexpectedToken(next, TokenType.T_CATCH);
result.setLocal(analyzer.removeScope().getVariables());
return result;
}
return null;
}
Aggregations