Ejemplo n.º 1
0
 @Override
 public String toString() {
   String str = "";
   if (production.items.size() > 0) {
     if (production.items.get(0) instanceof UserList) {
       String separator = ((UserList) production.items.get(0)).separator;
       str = contents.get(0) + " " + separator + " " + contents.get(1) + " ";
     } else
       for (int i = 0, j = 0; i < production.items.size(); i++) {
         ProductionItem pi = production.items.get(i);
         if (pi instanceof Terminal) {
           String terminall = pi.toString();
           terminall = terminall.substring(1, terminall.length() - 1);
           str += terminall + " ";
         } else if (pi instanceof Sort) str += contents.get(j++) + " ";
       }
   }
   return str;
 }
Ejemplo n.º 2
0
  @Override
  public boolean equals(Object obj) {
    if (obj == null) return false;
    if (this == obj) return true;
    if (!(obj instanceof TermCons)) return false;
    TermCons tc = (TermCons) obj;

    if (!tc.getSort().equals(this.sort)) return false;
    if (!tc.cons.equals(cons)) return false;

    if (tc.contents.size() != contents.size()) return false;

    for (int i = 0; i < tc.contents.size(); i++) {
      if (!tc.contents.get(i).equals(contents.get(i))) return false;
    }

    return true;
  }
Ejemplo n.º 3
0
 public Term getSubterm(int idx) {
   return contents.get(idx);
 }