Libraryless. Click here for Pure Java version (2689L/17K).
1 | sS gazelle_deepReplaceVars(SS map, S s, O... _) { |
2 | SS map2 = mapValues roundIfMultipleTokensUnlessCurlyBracketed(map); |
3 | ret gazelle_deepReplaceVars_impl(map2, s, _); |
4 | } |
5 | |
6 | sS gazelle_deepReplaceVars_impl(SS map, S s, O... _) { |
7 | LS tok = javaTokWithBrackets(s); |
8 | ret join(mapCodeTokens(tok, t -> { |
9 | //bool round = tok_isRoundBracketed(t); |
10 | //bool curly = tok_isCurlyBracketed(t); |
11 | S t2 = tok_deRoundOrCurlyBracket(t); |
12 | S t3 = map.get(t2); |
13 | ifdef gazelle_deepReplaceVars_debug |
14 | print("sub lookup: " + quote(t2) + " => " + quote(t3)); |
15 | endifdef |
16 | if (t3 != null) ret t3; |
17 | if (l(tok) == 3) ret t; |
18 | S t4 = gazelle_deepReplaceVars_impl(map, t2, _); |
19 | if (eq(t4, t2)) ret t; |
20 | //ret round ? roundBracket(t4) : curlyBracket(t4); |
21 | ret roundBracketOptIfMoreThanOneToken(t4); |
22 | })); |
23 | } |
Began life as a copy of #1025738
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025840 |
Snippet name: | gazelle_deepReplaceVars - doesn't auto-bracket map values |
Eternal ID of this version: | #1025840/13 |
Text MD5: | 93c355a9e362a0c0adfff4acb50836ee |
Transpilation MD5: | 8e57d93b36d678f98d6135921f286cbb |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-26 05:39:13 |
Source code size: | 832 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 268 / 437 |
Version history: | 12 change(s) |
Referenced in: | [show references] |