Libraryless. Click here for Pure Java version (5900L/33K).
1 | svoid tok_forOver(LS tok) { |
2 | jreplace (tok, "for <id> over <id>:", "for (int $2 = 0; $2 < l($4); $2++)"); |
3 | jreplace (tok, "for <id> backwards over <id>:", "for (int $2 = l($5)-1; $2 >= 0; $2--)"); |
4 | |
5 | // index var and implicitly typed element var |
6 | jreplace (tok, "for <id>, <id> over <id>: ", "for $2, var $4 over $6:"); |
7 | |
8 | // index var and explicitly typed element var |
9 | jreplace (tok, "for <id>, <id> <id> over <id>: {", "for (int $2 = 0; $2 < l($7); $2++) { $4 $5 = $7.get($2);"); |
10 | |
11 | jreplace (tok, "for <id>, <id> <id> backwards over <id>: {", "for (int $2 = l($8)-1; $2 >= 0; $2--) { $4 $5 = $8.get($2);"); |
12 | |
13 | jreplace_dyn_allowDollarRefs(tok, "for immutable <id> to <id>: {", cIdx -> { |
14 | S var = makeVar(); |
15 | ret "for \*var*/ to $5: { int $3 = \*var*/;"; |
16 | }); |
17 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034586 |
Snippet name: | tok_forOver |
Eternal ID of this version: | #1034586/1 |
Text MD5: | 375a49afce0d9059db65e50f1e90c859 |
Transpilation MD5: | c573221b0dfb2503cf628978049e1f2d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-19 06:09:47 |
Source code size: | 798 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 133 / 196 |
Referenced in: | [show references] |