static L ai_parse_toList1(S parse) { ret ai_parse_toList1(parse, curlySep()); } static L ai_parse_toList1(S parse, Pair sep) { assertNempty(sep.a); assertNempty(sep.b); int i = 0; new L stack; new StringBuilder buf; new L out; while ping (i < l(parse)) { if (substringAtIs(parse, i, sep.a)) { if (nempty(buf)) out.add(getAndClearStringBuilder(buf)); stack.add(i); i += l(sep.a); } else if (substringAtIs(parse, i, sep.b)) { int j = popLast(stack); i += l(sep.b); if (empty(stack)) out.add(substring(parse, j, i)); } else if (empty(stack)) buf.append(parse.charAt(i++)); else i++; } if (nempty(buf)) out.add(getAndClearStringBuilder(buf)); ret out; }