use of lucee.transformer.bytecode.statement.DoWhile in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method doStatement.
/**
* Liest ein do Statement ein.
* <br />
* EBNF:<br />
* <code>block spaces "while" spaces "(" spaces condition spaces ")";</code>
* @return do Statement
* @throws TemplateException
*/
private final DoWhile doStatement(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("do")) {
id = null;
if (!data.srcCode.isCurrent('{') && !data.srcCode.isCurrent(' ') && !data.srcCode.isCurrent('/')) {
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("do", '{') && !data.srcCode.forwardIfCurrent("do ") && !data.srcCode.forwardIfCurrent("do", '/')) {
data.srcCode.setPos(pos);
return null;
}
data.srcCode.previous();
}
// if(!data.srcCode.forwardIfCurrent("do",'{') && !data.srcCode.forwardIfCurrent("do ") && !data.srcCode.forwardIfCurrent("do",'/'))
// return null;
Position line = data.srcCode.getPosition();
Body body = new BodyBase(data.factory);
// data.srcCode.previous();
statement(data, body, CTX_DO_WHILE);
comments(data);
if (!data.srcCode.forwardIfCurrent("while", '('))
throw new TemplateException(data.srcCode, "do statement must have a while at the end");
DoWhile doWhile = new DoWhile(condition(data), body, line, data.srcCode.getPosition(), id);
if (!data.srcCode.forwardIfCurrent(')'))
throw new TemplateException(data.srcCode, "do statement must end with a [)]");
return doWhile;
}
Aggregations