// TODO: ignore N tokens static LS tok_groupPhrase(LS tok, S phrase) { LS tokPhrase = dropFirstAndLast(javaTok_cached(phrase)); L l = indicesOfSubListIC(tok, tokPhrase); for (int i : l) { int j = i+l(tokPhrase)-1; if (i == 1 && j == l(tok)-2) continue; S pre = get(tok, i-1), post = get(tok, j+1); if (endsWith(pre, "{") && startsWith(post, "}")) continue; tokPrepend(tok, i, "{"); tokAppend(tok, j, "}"); } ret tok; } sS tok_groupPhrase(S s, S phrase) { ret join(tok_groupPhrase(javaTok(s), phrase)); }