// i must point at the (possibly imaginary) opening bracket ("{") // index returned is index of closing bracket + 1 (or l(tok)) static int tok_findEndOfBlock(LS tok, int i) { ifclass IContentsIndexedList2 if (tok cast IContentsIndexedList2) ret tok_findEndOfBlock_IContentsIndexedList2_v2(tok, i); endif int j = i+2, level = 1, n = l(tok); while (j < n) { S t = tok.get(j); if ("{".equals(t)) ++level; else if ("}".equals(t)) --level; if (level == 0) return j+1; j += 2; } ret n; }