Пример #1
0
 /** Evaluate a boolean expression in executable SQL statement */
 public void execBoolSql(HplsqlParser.Bool_exprContext ctx) {
   StringBuilder sql = new StringBuilder();
   if (ctx.T_OPEN_P() != null) {
     sql.append("(");
     sql.append(evalPop(ctx.bool_expr(0)).toString());
     sql.append(")");
   } else if (ctx.bool_expr_atom() != null) {
     sql.append(evalPop(ctx.bool_expr_atom()).toString());
   } else if (ctx.bool_expr_logical_operator() != null) {
     sql.append(evalPop(ctx.bool_expr(0)).toString());
     sql.append(" " + ctx.bool_expr_logical_operator().getText() + " ");
     sql.append(evalPop(ctx.bool_expr(1)).toString());
   }
   exec.stackPush(sql);
 }
Пример #2
0
 /** Evaluate a boolean expression */
 public void execBool(HplsqlParser.Bool_exprContext ctx) {
   if (ctx.bool_expr_atom() != null) {
     eval(ctx.bool_expr_atom());
     return;
   }
   Var result = evalPop(ctx.bool_expr(0));
   if (ctx.T_OPEN_P() != null) {
     if (ctx.T_NOT() != null) {
       result.negate();
     }
   } else if (ctx.bool_expr_logical_operator() != null) {
     if (ctx.bool_expr_logical_operator().T_AND() != null) {
       if (result.isTrue()) {
         result = evalPop(ctx.bool_expr(1));
       }
     } else if (ctx.bool_expr_logical_operator().T_OR() != null) {
       if (!result.isTrue()) {
         result = evalPop(ctx.bool_expr(1));
       }
     }
   }
   exec.stackPush(result);
 }