/** * This function obtains a list with the subexpressions of a given expressions * * @param expr The original expresion * @return the list with all the subexpressions */ public static List<Expr> getListExpr(Expr expr) throws IllegalArgumentException { List<Expr> list = new ArrayList<Expr>(); if (expr instanceof NumExpr) { list.add(expr); } else if (expr instanceof RefExpr) { RefExpr refExpr = (RefExpr) expr; String strRefExpr = refExpr.getZName().getWord(); // The \emptyset expression will be ignored if (!strRefExpr.equals(UtilSymbols.emptySetSymbol())) list.add(expr); } else if (expr instanceof SetExpr) { list = ((SetExpr) expr).getZExprList(); } else if (expr instanceof TupleExpr) { list = ((TupleExpr) expr).getZExprList(); } else if (expr instanceof ApplExpr) { if (((ApplExpr) expr).getMixfix()) { // es una secuencia ZExprListImpl applList = (ZExprListImpl) ((SetExpr) (((ApplExpr) expr).getRightExpr())).getZExprList(); for (int i = 0; i < applList.size(); i++) { Expr elem = (((TupleExpr) (applList.get(i))).getZExprList()).get(1); list.add(elem); } } else { // es un valor negativo list.add(expr); } } else { throw new IllegalArgumentException(); } return list; }
public Boolean visitZName(ZName zName) { String zNameWord = zName.toString(); return zNameWord.endsWith("!") || zNameWord.endsWith(UtilSymbols.primeSymbol()); }