// themap is the replacement map in list form - in/out/in/out/... static S mapBasedReplace(L themap, S s) { L tok = javaTok(s); for (int i = 1; i < l(tok); i += 2) { for (int j = 0; j < l(themap); j += 2) { S x = themap.get(j), y = themap.get(j+1); L tokx = javaTok(x), toky = javaTok(y); mapBasedReplace_matchReplace(tok, i, tokx, toky); } } ret join(tok); } static void mapBasedReplace_matchReplace(L tok, int i, L tokx, L toky) { if (tokRegionMatchIC(tok, i, tokx)) { clearAllTokens(tok.subList(i, i+l(tokx)-2)); tok.set(i, join(toky)); } }