// keyword can comprise multiple tokens now (like "p-awt"} static L replaceKeywordBlock(L tok, S keyword, S beg, S end) { ret replaceKeywordBlock(tok, keyword, beg, end, false, null); } static L replaceKeywordBlock(L tok, S keyword, S beg, S end, O cond) { ret replaceKeywordBlock(tok, keyword, beg, end, false, cond); } static L replaceKeywordBlock(L tok, S keyword, S beg, S end, bool debug, O cond) { for (int n = 0; n < 1000; n++) { int i = jfind(tok, keyword + " {", cond); if (i < 0) break; int idx = findCodeTokens(tok, i, false, "{"); int j = findEndOfBracketPart(tok, idx); if (debug) { print(toUpper(keyword) + " BEFORE\n" + join(subList(tok, i, j))); print(" THEN " + join(subList(tok, j, j+10))); } //assertEquals("}", tok.get(j-1)); LS subList = subList(tok, i-1, idx); // N to somewhere tok.set(j-1, jreplaceExpandRefs(end, subList)); replaceTokens(tok, i, idx+1, jreplaceExpandRefs(beg, subList)); reTok(tok, i, j); if (debug) print(toUpper(keyword) + "\n" + join(subList(tok, i, j)) + "\n"); } ret tok; }