Exemplo n.º 1
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);
 }
Exemplo n.º 2
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);
     }
   }
 }
Exemplo n.º 3
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)));
      }
    }
  }