Search in sources :

Example 6 with TagIf

use of cn.bran.japid.compiler.Tag.TagIf in project japid42 by branaway.

the class JapidAbstractCompiler method handleOpenElseIf.

private void handleOpenElseIf(int i, String expr, boolean negative) {
    //		expr = expr.substring(1).trim();
    // end previous if shadow and star a new one
    verifyExpr(expr);
    Tag tagShadow = tagsStackShadow.peek();
    if (tagShadow instanceof TagIf) {
        tagsStackShadow.pop();
        // to close an open if
        // start a new if
        Tag.TagIf iftag = new Tag.TagIf(expr, parser.getLineNumber());
        pushToStack(iftag);
        expr = "} else if(" + (negative ? "!" : "") + "asBoolean(" + expr + ")) {";
        print(expr);
        markLine(parser.getLineNumber() + i);
        println();
    } else {
        throw new JapidCompilationException(template, parser.getLineNumber(), "the open \"else if\" statement is not properly matched to a previous if");
    }
}
Also used : TagIf(cn.bran.japid.compiler.Tag.TagIf) TagIf(cn.bran.japid.compiler.Tag.TagIf) TagInTag(cn.bran.japid.compiler.Tag.TagInTag)

Aggregations

TagIf (cn.bran.japid.compiler.Tag.TagIf)6 TagInTag (cn.bran.japid.compiler.Tag.TagInTag)6 JapidTemplate (cn.bran.japid.template.JapidTemplate)2 Matcher (java.util.regex.Matcher)2