@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; }