示例#1
0
  public TermCons(Element element, Context context) {
    super(element);
    this.sort = element.getAttribute(Constants.SORT_sort_ATTR);
    this.cons = element.getAttribute(Constants.CONS_cons_ATTR);
    this.production = context.conses.get(cons);
    assert this.production != null;

    contents = new ArrayList<Term>();
    List<Element> children = XML.getChildrenElements(element);
    for (Element e : children) contents.add((Term) JavaClassesFactory.getTerm(e));
  }
示例#2
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)));
      }
    }
  }