1 | sbool ctxExpandMacros_debug; |
2 | |
3 | static S ctxExpandMacros(S s, SS macros) {
|
4 | while true {
|
5 | S s2 = ctxExpandMacros_step(s, macros); |
6 | if (eq(s, s2)) ret s; |
7 | s = s2; |
8 | } |
9 | } |
10 | |
11 | static S ctxExpandMacros_step(S s, SS macros) {
|
12 | Matcher m = regexp("#([A-Z_0-9]+)#", s);
|
13 | while (m.find()) {
|
14 | if (ctxExpandMacros_debug) |
15 | print("Replacing " + m.group(1));
|
16 | S key = m.group(1); |
17 | S macro = macros.get(key); |
18 | if (macro == null) macro = "#\\\"\\+\\?@"; |
19 | s = s.replace(m.group(), macro); |
20 | } |
21 | ret s; |
22 | } |
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: | #1008851 |
| Snippet name: | ctxExpandMacros |
| Eternal ID of this version: | #1008851/7 |
| Text MD5: | 455ec9542ede44ae4ef2d8eabf4992de |
| Author: | stefan |
| Category: | javax / parsing |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-06-29 19:45:23 |
| Source code size: | 534 bytes / 22 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 819 / 882 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |