use of org.develnext.jphp.core.tokenizer.token.expr.operator.OrExprToken in project jphp by jphp-compiler.
the class TryCatchGenerator method processCatch.
public void processCatch(CatchStmtToken result, ListIterator<Token> iterator) {
Token next = nextToken(iterator);
if (!isOpenedBrace(next, BraceExprToken.Kind.SIMPLE))
unexpectedToken(next, "(");
List<FulledNameToken> exceptions = new ArrayList<>();
do {
next = nextToken(iterator);
if (!(next instanceof NameToken)) {
if (exceptions.isEmpty()) {
unexpectedToken(next, TokenType.T_STRING);
} else {
iterator.previous();
break;
}
}
FulledNameToken exception = analyzer.getRealName((NameToken) next);
exceptions.add(exception);
next = nextToken(iterator);
if (!(next instanceof OrExprToken)) {
iterator.previous();
break;
}
} while (true);
result.setExceptions(exceptions);
next = nextToken(iterator);
if (!(next instanceof VariableExprToken))
unexpectedToken(next, TokenType.T_VARIABLE);
VariableExprToken variable = (VariableExprToken) next;
result.setVariable(variable);
if (analyzer.getFunction() != null) {
analyzer.getFunction().variable(variable).setUnstable(true);
}
analyzer.getScope().addVariable(variable);
next = nextToken(iterator);
if (!isClosedBrace(next, BraceExprToken.Kind.SIMPLE))
unexpectedToken(next, ")");
BodyStmtToken body = analyzer.generator(BodyGenerator.class).getToken(nextToken(iterator), iterator);
result.setBody(body);
}
Aggregations