Libraryless. Click here for Pure Java version (10462L/58K).
1 | svoid tok_metaFor(LS tok) { |
2 | int i; |
3 | |
4 | jreplace(tok, "meta-for <id> also as", "meta-for $4 in $4,"); |
5 | |
6 | while ((i = jfind_any(tok, |
7 | "meta-for <id> in", |
8 | "meta-for <id> as")) >= 0) { |
9 | int iOpening = indexOf(tok, i, "{"); |
10 | int iClosing = tok_findEndOfBracketPart(tok, iOpening)-1; |
11 | int iVar = i+6, iFirstValue = iVar+4; |
12 | S var = tok.get(iVar); |
13 | LS values = identifiersOnly(subList(tok, iFirstValue, iOpening-1)); |
14 | LS body = subList(tok, iOpening+1, iClosing); |
15 | |
16 | tokReplace_reTok(tok, i, iClosing+1, |
17 | mapToLines(values, value -> |
18 | join(replaceInClonedList(body, var, value)))); |
19 | } |
20 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031922 |
Snippet name: | tok_metaFor |
Eternal ID of this version: | #1031922/11 |
Text MD5: | e50333930b0a0f8169e5c348ad2a19ee |
Transpilation MD5: | 984a99db28d896738fb89123504d0734 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-19 23:51:40 |
Source code size: | 646 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 172 / 300 |
Version history: | 10 change(s) |
Referenced in: | [show references] |