Examples of LogicalExpression


Examples of com.ebay.erl.mobius.core.criterion.LogicalExpression

    {
      this.tupleConstraint = aConstraint;
    }
    else
    {
      this.tupleConstraint = new LogicalExpression(this.tupleConstraint, aConstraint, Operator.AND);
    }
  }
View Full Code Here

Examples of expression.logical.LogicalExpression

  // as a list of conjunctions
  // Do not compute a complete DNF
  public static ArrayList<LogicalExpression> negate(TermSystem p,Node next){
    ArrayList<LogicalExpression> result = new ArrayList<LogicalExpression>();
      Node saveNext = next.cloneNode(true);
      LogicalExpression exp;
      try {
        exp = LogicalExprVisitor.parse(saveNext,p);
        addConjunct(exp,result);
      } catch (AnalyzeException e) {
        // TODO Auto-generated catch block
View Full Code Here

Examples of it.unito.di.logic.expression.LogicalExpression

        }
      break;
     
      case LOGICAL_EXPRESSION:
        logger.trace("Just added a FACT, reasoning on interaction state after adding "+elAdded);
        LogicalExpression el = (LogicalExpression)elAdded;
        if (condCommits != null) {
          logger.trace("Parsing CONDITIONAL commitments");
          for (Commitment condComm : condCommits) {
            logger.debug("Commitment antecedent: "+condComm.getAntecedent());
            if (condComm.getAntecedent().equals(el)) {
View Full Code Here

Examples of org.apache.camel.language.simple.ast.LogicalExpression

        if (token.getType().isUnary()) {
            return new UnaryExpression(token);
        } else if (token.getType().isBinary()) {
            return new BinaryExpression(token);
        } else if (token.getType().isLogical()) {
            return new LogicalExpression(token);
        } else if (token.getType().isNullValue()) {
            return new NullExpression(token);
        }

        // by returning null, we will let the parser determine what to do
View Full Code Here

Examples of org.apache.camel.language.simple.ast.LogicalExpression

            }
            SimpleNode token = nodes.get(i);
            SimpleNode right = i < nodes.size() - 1 ? nodes.get(i + 1) : null;

            if (token instanceof LogicalExpression) {
                LogicalExpression logical = (LogicalExpression) token;

                // remember the logical operator
                String operator = logical.getOperator().toString();

                if (left == null) {
                    throw new SimpleParserException("Logical operator " + operator + " has no left hand side token", token.getToken().getIndex());
                }
                if (!logical.acceptLeftNode(left)) {
                    throw new SimpleParserException("Logical operator " + operator + " does not support left hand side token " + left.getToken(), token.getToken().getIndex());
                }
                if (right == null) {
                    throw new SimpleParserException("Logical operator " + operator + " has no right hand side token", token.getToken().getIndex());
                }
                if (!logical.acceptRightNode(right)) {
                    throw new SimpleParserException("Logical operator " + operator + " does not support right hand side token " + left.getToken(), token.getToken().getIndex());
                }

                // pop previous as we need to replace it with this binary operator
                stack.pop();
View Full Code Here

Examples of org.apache.drill.common.expression.LogicalExpression

    CommonTokenStream tokens = new CommonTokenStream(lexer);

    ExprParser parser = new ExprParser(tokens);
    parser.setRegistry(new FunctionRegistry(DrillConfig.create()));
    parse_return ret = parser.parse();
    LogicalExpression e = ret.e;
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    System.out.println(mapper.writeValueAsString(e));

    // print the tree
View Full Code Here

Examples of org.apache.drill.common.expression.LogicalExpression

    @Override
    public LogicalExpression visitFunctionCall(FunctionCall call) {
      List<LogicalExpression> args = Lists.newArrayList();
      for (int i = 0; i < call.args.size(); ++i) {
        LogicalExpression newExpr = call.args.get(i).accept(this, null);
        args.add(newExpr);
      }

      return validateNewExpr(new FunctionCall(call.getDefinition(), args, call.getPosition()));
    }
View Full Code Here

Examples of org.apache.drill.common.expression.LogicalExpression

    }

    @Override
    public LogicalExpression visitIfExpression(IfExpression ifExpr) {
      List<IfExpression.IfCondition> conditions = Lists.newArrayList(ifExpr.conditions);
      LogicalExpression newElseExpr = ifExpr.elseExpression.accept(this, null);

      for (int i = 0; i < conditions.size(); ++i) {
        IfExpression.IfCondition condition = conditions.get(i);

        LogicalExpression newCondition = condition.condition.accept(this, null);
        LogicalExpression newExpr = condition.expression.accept(this, null);
        conditions.set(i, new IfExpression.IfCondition(newCondition, newExpr));
      }

      return validateNewExpr(IfExpression.newBuilder().setElse(newElseExpr).addConditions(conditions).build());
    }
View Full Code Here

Examples of org.apache.drill.common.expression.LogicalExpression

//      logger.debug(String.format("Call [%s] didn't match as the number of arguments provided [%d] were different than expected [%d]. ", call.getDefinition().getName(), parameters.length, call.args.size()));
      return false;
    }
    for(int i =0; i < parameters.length; i++){
      ValueReference param = parameters[i];
      LogicalExpression arg = call.args.get(i);
      if(!softCompare(param.type, arg.getMajorType())){
//        logger.debug(String.format("Call [%s] didn't match as the argument [%s] didn't match the expected type [%s]. ", call.getDefinition().getName(), arg.getMajorType(), param.type));
        return false;
      }
    }
   
View Full Code Here

Examples of org.apache.drill.common.expression.LogicalExpression

  public static void main(String[] args) throws Exception {
    String expr = "if( a == 1) then 4 else 2 end";
    ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    ExprParser parser = new ExprParser(tokens);
    LogicalExpression e = parser.parse().e;
    RecordPointer r = new UnbackedRecord();
    r.addField(new SchemaPath("a", ExpressionPosition.UNKNOWN), new IntegerScalar(3));
    SimpleEvaluationVisitor builder = new SimpleEvaluationVisitor(r);
    BasicEvaluator eval = e.accept(builder, null);
    DataValue v = eval.eval();
    System.out.println(v);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.