Search in sources :

Example 11 with Body

use of lucee.transformer.bytecode.Body 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 12 with Body

use of lucee.transformer.bytecode.Body 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;
}
Also used : Position(lucee.transformer.Position) TemplateException(lucee.runtime.exp.TemplateException) DoWhile(lucee.transformer.bytecode.statement.DoWhile) Body(lucee.transformer.bytecode.Body) ScriptBody(lucee.transformer.bytecode.ScriptBody) FunctionBody(lucee.transformer.bytecode.FunctionBody) BodyBase(lucee.transformer.bytecode.BodyBase)

Example 13 with Body

use of lucee.transformer.bytecode.Body 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;
}
Also used : Position(lucee.transformer.Position) TemplateException(lucee.runtime.exp.TemplateException) DoWhile(lucee.transformer.bytecode.statement.DoWhile) While(lucee.transformer.bytecode.statement.While) Body(lucee.transformer.bytecode.Body) ScriptBody(lucee.transformer.bytecode.ScriptBody) FunctionBody(lucee.transformer.bytecode.FunctionBody) BodyBase(lucee.transformer.bytecode.BodyBase)

Example 14 with Body

use of lucee.transformer.bytecode.Body in project Lucee by lucee.

the class AbstrCFMLScriptTransformer method defaultStatement.

/**
 * Liest ein default Statement ein
 * @return default Statement
 * @throws TemplateException
 */
private final boolean defaultStatement(ExprData data, Switch swit) throws TemplateException {
    if (!data.srcCode.forwardIfCurrent("default", ':'))
        return false;
    // int line=data.srcCode.getLine();
    Body body = new BodyBase(data.factory);
    swit.setDefaultCase(body);
    switchBlock(data, body);
    return true;
}
Also used : Body(lucee.transformer.bytecode.Body) ScriptBody(lucee.transformer.bytecode.ScriptBody) FunctionBody(lucee.transformer.bytecode.FunctionBody) BodyBase(lucee.transformer.bytecode.BodyBase)

Example 15 with Body

use of lucee.transformer.bytecode.Body in project Lucee by lucee.

the class AbstrCFMLScriptTransformer method finallyStatement.

private final boolean finallyStatement(ExprData data, TryCatchFinally tcf) throws TemplateException {
    if (!data.srcCode.forwardIfCurrent("finally", '{') && !data.srcCode.forwardIfCurrent("finally ") && !data.srcCode.forwardIfCurrent("finally", '/'))
        return false;
    // start (
    data.srcCode.previous();
    // ex block
    Body body = new BodyBase(data.factory);
    tcf.setFinally(body, data.srcCode.getPosition());
    statement(data, body, CTX_FINALLY);
    return true;
}
Also used : Body(lucee.transformer.bytecode.Body) ScriptBody(lucee.transformer.bytecode.ScriptBody) FunctionBody(lucee.transformer.bytecode.FunctionBody) BodyBase(lucee.transformer.bytecode.BodyBase)

Aggregations

Body (lucee.transformer.bytecode.Body)33 ScriptBody (lucee.transformer.bytecode.ScriptBody)21 BodyBase (lucee.transformer.bytecode.BodyBase)17 FunctionBody (lucee.transformer.bytecode.FunctionBody)15 Statement (lucee.transformer.bytecode.Statement)15 Tag (lucee.transformer.bytecode.statement.tag.Tag)12 Expression (lucee.transformer.expression.Expression)11 Position (lucee.transformer.Position)9 TemplateException (lucee.runtime.exp.TemplateException)8 TagLibTag (lucee.transformer.library.tag.TagLibTag)8 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)7 HasBody (lucee.transformer.bytecode.statement.HasBody)6 LitString (lucee.transformer.expression.literal.LitString)6 ArrayList (java.util.ArrayList)5 FunctionAsExpression (lucee.transformer.bytecode.expression.FunctionAsExpression)5 PrintOut (lucee.transformer.bytecode.statement.PrintOut)5 EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)5 TransformerException (lucee.transformer.TransformerException)4 StaticBody (lucee.transformer.bytecode.StaticBody)4 Literal (lucee.transformer.expression.literal.Literal)4