1 | static L<S> ai_parse_toList1(S parse) {
|
2 | ret ai_parse_toList1(parse, curlySep()); |
3 | } |
4 | |
5 | static L<S> ai_parse_toList1(S parse, Pair<S> sep) {
|
6 | assertNempty(sep.a); |
7 | assertNempty(sep.b); |
8 | int i = 0; |
9 | new L<Int> stack; |
10 | new StringBuilder buf; |
11 | new L<S> out; |
12 | while ping (i < l(parse)) {
|
13 | if (substringAtIs(parse, i, sep.a)) {
|
14 | if (nempty(buf)) out.add(getAndClearStringBuilder(buf)); |
15 | stack.add(i); |
16 | i += l(sep.a); |
17 | } else if (substringAtIs(parse, i, sep.b)) {
|
18 | int j = popLast(stack); |
19 | i += l(sep.b); |
20 | if (empty(stack)) |
21 | out.add(substring(parse, j, i)); |
22 | } else if (empty(stack)) |
23 | buf.append(parse.charAt(i++)); |
24 | else i++; |
25 | } |
26 | if (nempty(buf)) out.add(getAndClearStringBuilder(buf)); |
27 | ret out; |
28 | } |
Began life as a copy of #1013561
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1013566 |
| Snippet name: | ai_parse_toList1 |
| Eternal ID of this version: | #1013566/3 |
| Text MD5: | 1e1380f8e8cc596f5d2734fb9d944a84 |
| Author: | stefan |
| Category: | javax / general parsing |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-01-09 13:48:37 |
| Source code size: | 782 bytes / 28 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 594 / 640 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |