Search in sources :

Example 1 with TryStmtToken

use of org.develnext.jphp.core.tokenizer.token.stmt.TryStmtToken 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;
}
Also used : FinallyStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken) BodyGenerator(org.develnext.jphp.core.syntax.generators.manually.BodyGenerator) Token(org.develnext.jphp.core.tokenizer.token.Token) BodyStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.BodyStmtToken) VariableExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.VariableExprToken) FinallyStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken) BraceExprToken(org.develnext.jphp.core.tokenizer.token.expr.BraceExprToken) NameToken(org.develnext.jphp.core.tokenizer.token.expr.value.NameToken) FulledNameToken(org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken) TryStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.TryStmtToken) CatchStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.CatchStmtToken) CatchStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.CatchStmtToken) TryStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.TryStmtToken) BodyStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.BodyStmtToken)

Aggregations

BodyGenerator (org.develnext.jphp.core.syntax.generators.manually.BodyGenerator)1 Token (org.develnext.jphp.core.tokenizer.token.Token)1 BraceExprToken (org.develnext.jphp.core.tokenizer.token.expr.BraceExprToken)1 FulledNameToken (org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken)1 NameToken (org.develnext.jphp.core.tokenizer.token.expr.value.NameToken)1 VariableExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.VariableExprToken)1 BodyStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.BodyStmtToken)1 CatchStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.CatchStmtToken)1 FinallyStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken)1 TryStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.TryStmtToken)1