Search in sources :

Example 1 with Pair

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

the class AbstrCFMLScriptTransformer method elseStatement.

/**
 * Liest ein else Statement ein.
 * <br />
 * EBNF:<br />
 * <code>block;</code>
 * @return else Statement
 * @throws TemplateException
 */
private final boolean elseStatement(ExprData data, Condition cont) throws TemplateException {
    if (!data.srcCode.forwardIfCurrent("else", '{') && !data.srcCode.forwardIfCurrent("else ") && !data.srcCode.forwardIfCurrent("else", '/'))
        return false;
    // start (
    data.srcCode.previous();
    // ex block
    Body body = new BodyBase(data.factory);
    Pair p = cont.setElse(body, data.srcCode.getPosition(), null);
    statement(data, body, CTX_ELSE);
    p.end = data.srcCode.getPosition();
    return true;
}
Also used : Body(lucee.transformer.bytecode.Body) ScriptBody(lucee.transformer.bytecode.ScriptBody) FunctionBody(lucee.transformer.bytecode.FunctionBody) BodyBase(lucee.transformer.bytecode.BodyBase) Pair(lucee.transformer.bytecode.statement.Condition.Pair)

Example 2 with Pair

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

the class AbstrCFMLScriptTransformer method elseifStatement.

/**
 * Liest ein else if Statement ein.
 * <br />
 * EBNF:<br />
 * <code>spaces condition spaces ")" spaces block;</code>
 * @return else if Statement
 * @throws TemplateException
 */
private final boolean elseifStatement(ExprData data, Condition cont) throws TemplateException {
    int pos = data.srcCode.getPos();
    if (!data.srcCode.forwardIfCurrent("else"))
        return false;
    comments(data);
    if (!data.srcCode.forwardIfCurrent("if", '(')) {
        data.srcCode.setPos(pos);
        return false;
    }
    Position line = data.srcCode.getPosition();
    Body body = new BodyBase(data.factory);
    Pair pair = cont.addElseIf(condition(data), body, line, null);
    if (!data.srcCode.forwardIfCurrent(')'))
        throw new TemplateException(data.srcCode, "else if statement must end with a [)]");
    // ex block
    statement(data, body, CTX_ELSE_IF);
    pair.end = data.srcCode.getPosition();
    return true;
}
Also used : 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) Pair(lucee.transformer.bytecode.statement.Condition.Pair)

Aggregations

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