use of org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken in project jphp by jphp-compiler.
the class NamespaceGenerator method getToken.
@Override
public NamespaceStmtToken getToken(Token current, ListIterator<Token> iterator) {
if (current instanceof NamespaceStmtToken) {
NamespaceStmtToken result = (NamespaceStmtToken) current;
FulledNameToken name = analyzer.generator(NameGenerator.class).getToken(nextToken(iterator), iterator);
result.setName(name);
if (name == null)
iterator.previous();
analyzer.setNamespace(result);
processBody(result, iterator);
analyzer.setNamespace(NamespaceStmtToken.getDefault());
return result;
}
return null;
}
use of org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken 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, "(");
next = nextToken(iterator);
if (!(next instanceof NameToken))
unexpectedToken(next, TokenType.T_STRING);
FulledNameToken exception = analyzer.getRealName((NameToken) next);
result.setException(exception);
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);
}
use of org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken in project jphp by jphp-compiler.
the class ConstGenerator method getToken.
/*@SuppressWarnings("unchecked")
protected void processBody(ConstStmtToken result, ListIterator<Token> iterator){
Token current = nextToken(iterator);
if (!(current instanceof AssignExprToken))
unexpectedToken(current, "=");
ExprStmtToken value = analyzer.generator(SimpleExprGenerator.class).getToken(nextToken(iterator), iterator);
if (value == null)
unexpectedToken(nextToken(iterator));
result.setValue(value);
}*/
@Override
@SuppressWarnings("unchecked")
public ConstStmtToken getToken(Token current, ListIterator<Token> iterator) {
if (current instanceof ConstStmtToken) {
ConstStmtToken result = (ConstStmtToken) current;
Token prev = null;
if (analyzer.getClazz() == null)
result.setNamespace(analyzer.getNamespace());
while (true) {
Token next = analyzer.getClazz() == null ? nextToken(iterator) : nextTokenSensitive(iterator, ClassStmtToken.class);
if (next instanceof NameToken) {
if (next instanceof FulledNameToken && !((FulledNameToken) next).isProcessed(NamespaceUseStmtToken.UseType.CONSTANT))
unexpectedToken(next, TokenType.T_STRING);
Token token = nextToken(iterator);
if (!(token instanceof AssignExprToken))
unexpectedToken(token, "=");
ExprStmtToken value = analyzer.generator(SimpleExprGenerator.class).getToken(nextToken(iterator), iterator, Separator.COMMA_OR_SEMICOLON, null);
if (!isBreak(iterator.previous())) {
iterator.next();
}
if (value == null)
unexpectedToken(iterator.previous());
result.add((NameToken) next, value);
} else if (next instanceof CommaToken) {
if (prev instanceof CommaToken)
unexpectedToken(next);
prev = next;
} else if (isBreak(next)) {
break;
} else
unexpectedToken(next, TokenType.T_STRING);
}
return result;
}
return null;
}
Aggregations