Search in sources :

Example 1 with Condition

use of lucee.transformer.bytecode.statement.Condition in project Lucee by lucee.

the class AbstrCFMLScriptTransformer method ifStatement.

/**
 * Liest ein if Statement ein.
 * <br />
 * EBNF:<br />
 * <code>spaces condition spaces ")" spaces block {"else if" spaces "(" elseifStatement spaces }
 *			 [("else"  spaces "(" | "else ") elseStatement spaces];</code>
 * @return if Statement
 * @throws TemplateException
 */
private final Statement ifStatement(ExprData data) throws TemplateException {
    if (!data.srcCode.forwardIfCurrent("if", '('))
        return null;
    Position line = data.srcCode.getPosition();
    Body body = new BodyBase(data.factory);
    Condition cont = new Condition(data.factory, condition(data), body, line, null);
    if (!data.srcCode.forwardIfCurrent(')'))
        throw new TemplateException(data.srcCode, "if statement must end with a [)]");
    // ex block
    statement(data, body, CTX_IF);
    // else if
    comments(data);
    while (elseifStatement(data, cont)) {
        comments(data);
    }
    // else
    if (elseStatement(data, cont)) {
        comments(data);
    }
    cont.setEnd(data.srcCode.getPosition());
    return cont;
}
Also used : Condition(lucee.transformer.bytecode.statement.Condition) Position(lucee.transformer.Position) TemplateException(lucee.runtime.exp.TemplateException) Body(lucee.transformer.bytecode.Body) ScriptBody(lucee.transformer.bytecode.ScriptBody) FunctionBody(lucee.transformer.bytecode.FunctionBody) BodyBase(lucee.transformer.bytecode.BodyBase)

Aggregations

TemplateException (lucee.runtime.exp.TemplateException)1 Position (lucee.transformer.Position)1 Body (lucee.transformer.bytecode.Body)1 BodyBase (lucee.transformer.bytecode.BodyBase)1 FunctionBody (lucee.transformer.bytecode.FunctionBody)1 ScriptBody (lucee.transformer.bytecode.ScriptBody)1 Condition (lucee.transformer.bytecode.statement.Condition)1