Search in sources :

Example 1 with Elseif_directiveContext

use of jetbrick.template.parser.grammer.JetTemplateParser.Elseif_directiveContext in project jetbrick-template-1x by subchen.

the class JetTemplateCodeVisitor method visitIf_directive.

@Override
public Code visitIf_directive(If_directiveContext ctx) {
    BlockCode code = scopeCode.createBlockCode(16);
    SegmentCode expr_code = (SegmentCode) ctx.expression().accept(this);
    code.addLine("if (" + get_if_expression_source(expr_code) + ") { // line: " + ctx.getStart().getLine());
    scopeCode = scopeCode.push();
    code.addChild(ctx.block().accept(this));
    scopeCode = scopeCode.pop();
    code.addLine("}");
    // elseif ...
    List<Elseif_directiveContext> elseif_directive_list = ctx.elseif_directive();
    for (Elseif_directiveContext elseif_directive : elseif_directive_list) {
        code.addChild(elseif_directive.accept(this));
    }
    // else ...
    Else_directiveContext else_directive = ctx.else_directive();
    if (else_directive != null) {
        code.addChild(else_directive.accept(this));
    }
    return code;
}
Also used : BlockCode(jetbrick.template.parser.code.BlockCode) Elseif_directiveContext(jetbrick.template.parser.grammer.JetTemplateParser.Elseif_directiveContext) Else_directiveContext(jetbrick.template.parser.grammer.JetTemplateParser.Else_directiveContext) SegmentCode(jetbrick.template.parser.code.SegmentCode)

Aggregations

BlockCode (jetbrick.template.parser.code.BlockCode)1 SegmentCode (jetbrick.template.parser.code.SegmentCode)1 Else_directiveContext (jetbrick.template.parser.grammer.JetTemplateParser.Else_directiveContext)1 Elseif_directiveContext (jetbrick.template.parser.grammer.JetTemplateParser.Elseif_directiveContext)1