static O ai_parse_toList(S parse) { ret ai_parse_toList(parse, curlySep()); } // returns L or S static O ai_parse_toList(S parse, Pair<S> sep) { assertNempty(sep.a); assertNempty(sep.b); int i = 0; new L<Int> 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)); i += l(sep.a); stack.add(i); } else if (substringAtIs(parse, i, sep.b)) { int j = popLast(stack); if (empty(stack)) //out.add(ll(substring(parse, j, i))); out.add(ll(ai_parse_toList(substring(parse, j, i)))); i += l(sep.b); } else if (empty(stack)) buf.append(parse.charAt(i++)); else i++; } //if (empty(out)) ret parse; if (nempty(buf)) out.add(getAndClearStringBuilder(buf)); ret recursivelyUnpackSingleElementList(out); }
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: | #1013561 | 
| Snippet name: | ai_parse_toList | 
| Eternal ID of this version: | #1013561/14 | 
| Text MD5: | fcb85aa88391f0b0202e8b6ab0bfd29e | 
| 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 14:01:34 | 
| Source code size: | 926 bytes / 31 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 672 / 754 | 
| Version history: | 13 change(s) | 
| Referenced in: | [show references] |