// "$1" is first code token, "$2" second code token etc. static S jreplaceExpandRefs(S s, L tokref) { if (!contains(s, '$')) ret s; L tok = javaTok(s); for (int i = 1; i < l(tok); i += 2) { S t = tok.get(i); if (t.startsWith("$") && isInteger(t.substring(1))) { S x = tokref.get(-1+parseInt(t.substring(1))*2); tok.set(i, x); } else if (t.equals("\\")) { tok.set(i, ""); i += 2; } } ret join(tok); }