Search in sources :

Example 1 with TernaryExpression

use of org.beetl.core.statement.TernaryExpression in project beetl2.0 by javamonkey.

the class AntlrProgramBuilder method parseTernaryExpression.

protected Expression parseTernaryExpression(TernaryExpContext ctx) {
    Expression cond = this.parseExpress(ctx.expression(0));
    Expression a = this.parseExpress(ctx.expression(1));
    Expression b = null;
    if (ctx.COLON() == null) {
        b = null;
    } else {
        b = this.parseExpress(ctx.expression(2));
    }
    TerminalNode tn = (TerminalNode) ctx.getChild(1);
    return new TernaryExpression(cond, a, b, this.getBTToken(tn.getSymbol()));
}
Also used : TernaryExpression(org.beetl.core.statement.TernaryExpression) ContentBodyExpression(org.beetl.core.statement.ContentBodyExpression) ArthExpression(org.beetl.core.statement.ArthExpression) JsonMapExpression(org.beetl.core.statement.JsonMapExpression) CompareExpression(org.beetl.core.statement.CompareExpression) FunctionExpression(org.beetl.core.statement.FunctionExpression) IncDecExpression(org.beetl.core.statement.IncDecExpression) Expression(org.beetl.core.statement.Expression) AndExpression(org.beetl.core.statement.AndExpression) StatementExpression(org.beetl.core.statement.StatementExpression) NativeCallExpression(org.beetl.core.statement.NativeCallExpression) NegExpression(org.beetl.core.statement.NegExpression) FormatExpression(org.beetl.core.statement.FormatExpression) TernaryExpression(org.beetl.core.statement.TernaryExpression) OrExpression(org.beetl.core.statement.OrExpression) JsonArrayExpression(org.beetl.core.statement.JsonArrayExpression) NotBooleanExpression(org.beetl.core.statement.NotBooleanExpression) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode)

Aggregations

TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)1 AndExpression (org.beetl.core.statement.AndExpression)1 ArthExpression (org.beetl.core.statement.ArthExpression)1 CompareExpression (org.beetl.core.statement.CompareExpression)1 ContentBodyExpression (org.beetl.core.statement.ContentBodyExpression)1 Expression (org.beetl.core.statement.Expression)1 FormatExpression (org.beetl.core.statement.FormatExpression)1 FunctionExpression (org.beetl.core.statement.FunctionExpression)1 IncDecExpression (org.beetl.core.statement.IncDecExpression)1 JsonArrayExpression (org.beetl.core.statement.JsonArrayExpression)1 JsonMapExpression (org.beetl.core.statement.JsonMapExpression)1 NativeCallExpression (org.beetl.core.statement.NativeCallExpression)1 NegExpression (org.beetl.core.statement.NegExpression)1 NotBooleanExpression (org.beetl.core.statement.NotBooleanExpression)1 OrExpression (org.beetl.core.statement.OrExpression)1 StatementExpression (org.beetl.core.statement.StatementExpression)1 TernaryExpression (org.beetl.core.statement.TernaryExpression)1