Search in sources :

Example 1 with FinallyStmtToken

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);
}
Also used : FinallyStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken) CatchStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.CatchStmtToken)

Example 2 with FinallyStmtToken

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;
}
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

CatchStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.CatchStmtToken)2 FinallyStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken)2 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 TryStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.TryStmtToken)1