Package expression

Examples of expression.Expression


    if (e instanceof NotExpression) {
      return (LogicalExpression)((NotExpression)e).arg1();
    }
    // a=>b is (not a or b) so returns return (a and not b)
    else if (e instanceof ImpliesExpression){
      Expression a1 = ((ImpliesExpression)e).arg1();
      LogicalExpression a2 = (LogicalExpression)((ImpliesExpression)e).arg2();
      return new AndExpression(a1,negateCase(a2));
    }
    // returns the negation
    else return new NotExpression(e);
View Full Code Here


 
  private static void addDisjunct(ArrayList<Expression> result, Expression e) {
    if (!(e instanceof OrExpression))
      result.add(e);
    else {
      Expression arg1 = ((OrExpression)e).arg1();
      addDisjunct(result,arg1);
      Expression arg2 = ((OrExpression)e).arg2();
      addDisjunct(result,arg2);
    }
  }
View Full Code Here

  ConstraintException {
    String op = ((Element) n).getTagName();
    ChildIterator child = new ChildIterator(n);
    if (!child.hasMoreChild()) exception(2);
    Node next = child.next();
    Expression first = IntExprVisitor.parse(next,p);
    if (!child.hasMoreChild()) exception(2);
    next = child.next();
    Expression second = IntExprVisitor.parse(next,p);
    return relation(p,op,first,second);
  }
View Full Code Here

    // stop on the first case which has a solution (i.e counter-example)
    int i = 0;
    Solution result = new Solution();
    while (i<cases.size() && result.empty()) {
      result = new Solution();
      Expression c = cases.get(i);
      constSyst.addConstraint(c);
      if (multi)
        System.out.println("Case # " + (i+1));
      System.out.println(constSyst);
      if (timeout==-1)
View Full Code Here

    if (multi)
      System.out.println("There are " + cases.size() + " cases to solve");

    int i=0;
    while (i<cases.size()) {
      Expression c = cases.get(i);
      Solution result = new Solution();
      constSyst.addConstraint(c);
      System.out.println(constSyst);
      if (timeout==-1)
        constSyst.solve(result,false);
View Full Code Here

public class IntExprVisitor extends XMLVisitor {

  // <!ENTITY % ExprInt "(IDSExprIdent|IDSExprPlus|IDSExprMinus|IDSExprTimes|IDSExprDecimalIntegerLiteral
  // |IDSExprParenthesis|IDSExprJMLResult)">
   static protected Expression parse(Node n,TermSystem p) throws AnalyzeException,  ConstraintException {
    Expression result = null;
//    System.out.println(n.getNodeName());
    if (isIntIdent(n)) {
      String name = parseIdent(n);
      if (!p.containsIntVar(name)) 
        result = p.addIntVar(name);
View Full Code Here

  /** add a constraint into a concrete solver*/
  protected abstract void addSimple(Expression e,IntegerVarBlock i);
 
  public void add(Constraint c,IntegerVarBlock i){
    Expression e = c.getExpression();
    if (isAnd(e))
      addMultiple(e,i);
    else addSimple(e,i);
  }
View Full Code Here

    else addSimple(e,i);
  }
 
  // to add a conjunction as a list of conjuncts
  private void addMultiple(Expression e,IntegerVarBlock i) {
    Expression arg1 = ((AndExpression)e).arg1();
    Expression arg2 = ((AndExpression)e).arg2();
    if (isAnd(arg1))
      addMultiple(arg1,i);
    else addSimple(arg1, i);
    if (isAnd(arg2))
      addMultiple(arg2,i);
View Full Code Here

  static private Expression intOperator(Node n,TermSystem p)
  throws AnalyzeException, ConstraintException {
    String operator = ((Element) n).getTagName();
    ChildIterator child = new ChildIterator(n);
    Node next = child.next();
    Expression first = parse(next,p);
    if (!child.hasMoreChild()) exception(1);
    Expression second = intOperatorAux(child,p, operator);
    Expression expr = null;
    if (isPlus(operator)) expr = new PlusExpression(first,second);
    else if (isMinus(operator)) expr = new MinusExpression(first,second);
    else if (isTimes(operator)) expr = new TimeExpression(first,second);
    else expr = new DivExpression(first,second);
//    ExpressionName result = p.exprTable.addExpression(expr);
View Full Code Here

  // m�thode r�cursive pour analyser tous les arguments
  static private Expression intOperatorAux(ChildIterator child,TermSystem p, String op)
  throws AnalyzeException, ConstraintException {

    Node next = child.next();
    Expression first = parse(next,p);
    if (child.hasMoreChild()) {
      Expression second = intOperatorAux(child,p,op);
      Expression expr = null;
      if (isPlus(op)) expr = new PlusExpression(first,second);
      else if (isMinus(op))expr = new MinusExpression(first,second);
      else if (isTimes(op)) expr = new TimeExpression(first,second);
      else expr = new DivExpression(first,second);
      return expr;
View Full Code Here

TOP

Related Classes of expression.Expression

Copyright © 2018 www.massapicom. 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.