// i must point at the opening bracket ("<") // index returned is index of closing bracket or comma static int tok_findEndOfTypeArg(L cnc, int i) { int j = i+2, level = 1; while (j < cnc.size()) { S t = cnc.get(j); if (t.equals("<")) ++level; else if (t.equals(">")) --level; if (level == 0 || level == 1 && eq(t, ",")) return j; ++j; } ret cnc.size(); }