Package aterm

Examples of aterm.ATermList


  public ATerm dictGet(ATerm key) {
    if (isEmpty()) {
      return null;
    }

    ATermList pair = (ATermList) first;

    if (key.equals(pair.getFirst())) {
      return pair.getNext().getFirst();
    }

    return next.dictGet(key);
  }
View Full Code Here


    return next.dictGet(key);
  }

  public ATermList dictPut(ATerm key, ATerm value) {
    if (isEmpty()) {
      ATermList pair = getEmpty().insert(value).insert(key);
      return getEmpty().insert(pair);
    }

    ATermList pair = (ATermList) first;
    if (key.equals(pair.getFirst())) {
      pair = getEmpty().insert(value).insert(pair);
      return next.insert(pair);

    }
View Full Code Here

  public ATermList dictRemove(ATerm key) {
    if (isEmpty()) {
      return this;
    }

    ATermList pair = (ATermList) first;

    if (key.equals(pair.getFirst())) {
      return next;
    }

    return (ATermList) next.dictRemove(key).insert(first).setAnnotations(getAnnotations());
  }
View Full Code Here

    int type = ac.type;
    if(type == ATerm.APPL){
      AFun fun = (AFun) ac.tempTerm;
      constructedTerm = factory.makeAppl(fun, subTerms, ac.annos);
    }else if(type == ATerm.LIST){
      ATermList list = factory.makeList();
      for(int i = subTerms.length - 1; i >= 0; i--){
        list = factory.makeList(subTerms[i], list);
      }

      if(ac.hasAnnos) list = (ATermList) list.setAnnotations(ac.annos);

      constructedTerm = list;
    }else if(type == ATerm.PLACEHOLDER){
      ATerm placeholder = factory.makePlaceholder(subTerms[0]);
View Full Code Here

    return this;
  }

  public boolean equivalent(SharedObject obj){
    if(obj instanceof ATermList){
      ATermList peer = (ATermList) obj;
      if(peer.getType() != getType()) return false;
     
      return (peer.getFirst() == first && peer.getNext() == next && peer.getAnnotations().equals(getAnnotations()));
    }
   
    return false;
  }
View Full Code Here

   
    return false;
  }

  public ATermList insert(ATerm el){
    ATermList tail = (!this.hasAnnotations()) ? this : ((ATermList) this.removeAnnotations());
   
    return getPureFactory().makeList(el, tail);
  }
View Full Code Here

    return make(first, next, annos);
  }

  protected boolean match(ATerm pattern, List<Object> list) {
    if (pattern.getType() == LIST) {
      ATermList l = (ATermList) pattern;

      if (l.isEmpty()) {
        return this.isEmpty();
      }

      if (l.getFirst().getType() == PLACEHOLDER) {
        ATerm ph_type = ((ATermPlaceholder) l.getFirst()).getPlaceholder();
        if (ph_type.getType() == APPL) {
          ATermAppl appl = (ATermAppl) ph_type;
          if (appl.getName().equals("list")
              && appl.getArguments().isEmpty()) {
            list.add(this);
            return true;
              }
        }
      }

      if (!isEmpty()) {
        List<Object> submatches = first.match(l.getFirst());
        if (submatches == null) {
          return false;
        }

        list.addAll(submatches);

        submatches = next.match(l.getNext());

        if (submatches == null) {
          return false;
        }

        list.addAll(submatches);
        return true;
      }
      return l.isEmpty();
    }

    return super.match(pattern, list);
  }
View Full Code Here

        ATerm ph_type = ((ATermPlaceholder) pattern_arg)
          .getPlaceholder();
        if (ph_type.getType() == APPL) {
          ATermAppl appl = (ATermAppl) ph_type;
          if (appl.getName().equals("list") && appl.getArguments().isEmpty()) {
            ATermList result = getPureFactory().getEmpty();
            for (int j = args.length - 1; j >= i; j--) {
              result = result.insert(args[j]);
            }
            list.add(result);
            return true;
          }
        }
View Full Code Here

  public AFun getAFun() {
    return fun;
  }

  public ATermList getArguments() {
    ATermList result = getPureFactory().getEmpty();

    for (int i = args.length - 1; i >= 0; i--) {
      result = result.insert(args[i]);
    }

    return result;
  }
View Full Code Here

    for(int i = 0; i < args.length; i++){
      newargs[i] = args[i].make(arguments);
    }
   
    PureFactory pf = getPureFactory();
    ATermList empty = pf.getEmpty();
   
    ATermList annos = getAnnotations();
    ATermList tempAnnos = empty;
    while(annos != empty){
      tempAnnos = pf.makeList(annos.getFirst().make(arguments), tempAnnos);
      annos = annos.getNext();
    }
    ATermList newAnnos = tempAnnos.reverse();
   
    return getPureFactory().makeAppl(fun, newargs, newAnnos);
  }
View Full Code Here

TOP

Related Classes of aterm.ATermList

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.