sS structure_convertTokenMarkersToExplicit(S s) { ret join(structure_convertTokenMarkersToExplicit(javaTokForStructure(s))); } static LS structure_convertTokenMarkersToExplicit(LS tok) { // find references & convert to explicit new TreeSet refs; for (int i = 1; i < l(tok); i += 2) { S t = tok.get(i); if (t.startsWith("t") && isInteger(t.substring(1))) { refs.add(parseInt(t.substring(1))); tok.set(i, "r" + substring(t, 1)); } } if (empty(refs)) ret tok; // add markers for (int i : refs) { int idx = i*2+1; if (idx >= l(tok)) continue; // broken structure S t = ""; if (endsWithLetterOrDigit(tok.get(idx-1))) t = " "; tok.set(idx, t + "m" + i + " " + tok.get(idx)); } ret tok; }