Search in sources :

Example 11 with SemicolonToken

use of org.develnext.jphp.core.tokenizer.token.SemicolonToken in project jphp by jphp-compiler.

the class NamespaceGenerator method processBody.

protected void processBody(NamespaceStmtToken namespace, ListIterator<Token> iterator) {
    Token next = nextToken(iterator);
    if (next instanceof SemicolonToken) {
        List<Token> tree = analyzer.process(iterator);
        namespace.setTree(tree);
        namespace.setTokenRegistered(true);
    } else if (isOpenedBrace(next, BraceExprToken.Kind.BLOCK)) {
        boolean done = false;
        List<Token> tree = new ArrayList<Token>();
        while (iterator.hasNext()) {
            Token item = analyzer.processNext(iterator);
            if (isClosedBrace(item, BraceExprToken.Kind.BLOCK)) {
                done = true;
                break;
            }
            tree.add(item);
        }
        if (!done)
            nextToken(iterator);
        namespace.setTree(tree);
    } else
        unexpectedToken(next);
}
Also used : SemicolonToken(org.develnext.jphp.core.tokenizer.token.SemicolonToken) Token(org.develnext.jphp.core.tokenizer.token.Token) NamespaceStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.NamespaceStmtToken) BraceExprToken(org.develnext.jphp.core.tokenizer.token.expr.BraceExprToken) FulledNameToken(org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken) SemicolonToken(org.develnext.jphp.core.tokenizer.token.SemicolonToken) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

SemicolonToken (org.develnext.jphp.core.tokenizer.token.SemicolonToken)11 Token (org.develnext.jphp.core.tokenizer.token.Token)9 BraceExprToken (org.develnext.jphp.core.tokenizer.token.expr.BraceExprToken)9 CommaToken (org.develnext.jphp.core.tokenizer.token.expr.CommaToken)8 CommentToken (org.develnext.jphp.core.tokenizer.token.CommentToken)6 AssignExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.AssignExprToken)6 ValueIfElseToken (org.develnext.jphp.core.tokenizer.token.expr.operator.ValueIfElseToken)4 ArrayList (java.util.ArrayList)3 ColonToken (org.develnext.jphp.core.tokenizer.token.ColonToken)3 ValueExprToken (org.develnext.jphp.core.tokenizer.token.expr.ValueExprToken)3 NameToken (org.develnext.jphp.core.tokenizer.token.expr.value.NameToken)3 Tokenizer (org.develnext.jphp.core.tokenizer.Tokenizer)2 DynamicAccessExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.DynamicAccessExprToken)2 DoubleExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.DoubleExprToken)2 IntegerExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken)2 StaticAccessExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.StaticAccessExprToken)2 StringExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.StringExprToken)2 Test (org.junit.Test)2 Context (php.runtime.env.Context)2 List (java.util.List)1