Пример #1
0
 // Check the input signature
 public void checkInputSignature(ATermList sigs) {
   while (!sigs.isEmpty()) {
     ATermAppl sig = (ATermAppl) sigs.getFirst();
     sigs = sigs.getNext();
     if (!sigTable.containsKey(sig)) {
       // Sorry, but the term is not in the input signature!
       notInInputSignature(sig);
     }
   }
 }
Пример #2
0
 /**
  * Filter non-primes
  *
  * @param numbers
  */
 private ATermList filterNonPrimes(ATermList numbers) {
   ATermList primes = factory.makeList();
   numbers = numbers.getNext();
   while (!numbers.isEmpty()) {
     ATermInt prime = (ATermInt) numbers.getFirst();
     numbers = filterMultiples(prime.getInt(), numbers);
     primes = primes.append(prime);
   }
   return factory.makeList(factory.makeInt(1), primes);
 }
Пример #3
0
  /**
   * Filter multiples of n.
   *
   * @param n
   * @param numbers
   */
  private ATermList filterMultiples(int n, ATermList numbers) {
    int nr, len = numbers.getLength();

    for (int i = 0; i < len; i++) {
      ATermInt el = (ATermInt) numbers.elementAt(i);
      nr = el.getInt();
      if (nr % n == 0) {
        len--;
        numbers = numbers.removeElementAt(i);
      }
    }
    return numbers;
  }
Пример #4
0
  @Override
  // XXX(Leo_Roos;Nov 18, 2011) leads to many recursive calls, a possible
  // reason why there has to be such a big stack size in order to run
  // Tigerseye
  public Visitable visitList(ATermList arg) throws VisitFailure {
    // save annotations
    ATermList annotations = arg.getAnnotations();

    int childCount = arg.getChildCount();
    for (int i = 0; i < childCount; i++) {
      ATerm currentAterm = arg.elementAt(i);
      ATerm t = (ATerm) currentAterm.accept(this);

      if (t != currentAterm) {
        arg = arg.replace(t, i);
      }
    }

    // restore annotations
    arg = (ATermList) arg.setAnnotations(annotations);

    return arg;
  }
Пример #5
0
  public TermCons(ATermAppl atm, Context context) {
    super(atm);
    this.cons = atm.getName();
    this.sort = StringUtil.getSortNameFromCons(cons);
    this.production = context.conses.get(cons);
    assert this.production != null;

    contents = new ArrayList<Term>();
    if (atm.getArity() == 0) {
      contents = new ArrayList<Term>();
    } else if (atm.getArgument(0) instanceof ATermList) {
      ATermList list = (ATermList) atm.getArgument(0);
      for (; !list.isEmpty(); list = list.getNext()) {
        if (isColon(list.getFirst())) continue;
        contents.add((Term) JavaClassesFactory.getTerm(list.getFirst()));
      }
      contents.add(new ListTerminator(sort, null));
    } else {
      for (int i = 0; i < atm.getArity(); i++) {
        if (isColon(atm.getArgument(i))) continue;
        contents.add((Term) JavaClassesFactory.getTerm(atm.getArgument(i)));
      }
    }
  }