/** Private helper for the yield method. */ private void yieldAppl(ATermAppl appl, StringBuilder builder) { for (ATerm t : (ATermList) appl.getArgument(APPL_ARGS)) { if (t instanceof ATermAppl) { ATermAppl arg = (ATermAppl) t; if (arg.getAFun() == applFun) { yieldAppl(arg, builder); } else { throw new IllegalArgumentException("Don't know how to yield " + arg); } } else if (t instanceof ATermInt) { ATermInt arg = (ATermInt) t; builder.append((char) arg.getInt()); } else { throw new IllegalArgumentException("Don't know how to yield " + t); } } }
/** * Yields a parse tree (parsetree or appl) to a String. * * @author Martin Bravenboer */ public String yield(ATerm parsetree) { StringBuilder builder = new StringBuilder(); yield(parsetree, builder); return builder.toString(); }