// @ requires iter.hasNext(); private <T extends IExpr> String rightassoc(String fcnname, Iterator<T> iter) throws IVisitor.VisitorException { T n = iter.next(); if (!iter.hasNext()) { return n.accept(this); } else { StringBuilder sb = new StringBuilder(); sb.append("("); sb.append(fcnname); sb.append(" "); sb.append(n.accept(this)); sb.append(" "); sb.append(rightassoc(fcnname, iter)); sb.append(")"); return sb.toString(); } }
/** A static helper method that sets the position of an AST node, but returns the same type */ protected static <T extends IPosable> T setPos(T t, IPos pos) { t.setPos(pos); return t; }