sbool ctxExpandMacros_debug; static S ctxExpandMacros(S s, SS macros) { while true { S s2 = ctxExpandMacros_step(s, macros); if (eq(s, s2)) ret s; s = s2; } } static S ctxExpandMacros_step(S s, SS macros) { Matcher m = regexp("#([A-Z_0-9]+)#", s); while (m.find()) { if (ctxExpandMacros_debug) print("Replacing " + m.group(1)); S key = m.group(1); S macro = macros.get(key); if (macro == null) macro = "#\\\"\\+\\?@"; s = s.replace(m.group(), macro); } ret s; }
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: | 562 / 629 |
Version history: | 6 change(s) |
Referenced in: | [show references] |