use of lucee.transformer.bytecode.statement.While in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method whileStatement.
/**
* Liest ein while Statement ein.
* <br />
* EBNF:<br />
* <code>spaces condition spaces ")" spaces block;</code>
* @return while Statement
* @throws TemplateException
*/
private final While whileStatement(ExprData data) throws TemplateException {
int pos = data.srcCode.getPos();
// id
String id = variableDec(data, false);
if (id == null) {
data.srcCode.setPos(pos);
return null;
}
if (id.equalsIgnoreCase("while")) {
id = null;
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent('(')) {
data.srcCode.setPos(pos);
return null;
}
} else {
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent(':')) {
data.srcCode.setPos(pos);
return null;
}
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent("while", '(')) {
data.srcCode.setPos(pos);
return null;
}
}
Position line = data.srcCode.getPosition();
Body body = new BodyBase(data.factory);
While whil = new While(condition(data), body, line, null, id);
if (!data.srcCode.forwardIfCurrent(')'))
throw new TemplateException(data.srcCode, "while statement must end with a [)]");
statement(data, body, CTX_WHILE);
whil.setEnd(data.srcCode.getPosition());
return whil;
}
Aggregations