Transpiled version (4477L) is out of date.
1 | // macro declareS { S s = blubbi(); } |
2 | // |
3 | // void myThing { |
4 | // declareS // expands to: S s = blubbi(); |
5 | // print(s); |
6 | // } |
7 | svoid tok_localMacro(LS tok) { |
8 | int i; |
9 | while ping ((i = jfind_reversed(tok, "macro <id> {")) >= 0) { |
10 | S macroName = tok.get(i+2); |
11 | int iMacroOpeningBracket = i+4; |
12 | int iMacroClosingBracket = findEndOfBlock(tok, iMacroOpeningBracket)-1; |
13 | |
14 | S replacement = joinSubList(tok, iMacroOpeningBracket+1, iMacroClosingBracket); |
15 | |
16 | // do the replacement |
17 | print("Replacing macro " + macroName + " with <" + trim(replacement) + ">"); |
18 | |
19 | int end = findEndOfBlock(tok, iMacroClosingBracket)-1; |
20 | for ping (int j = iMacroClosingBracket+2; j < end; j += 2) |
21 | if (eq(tok.get(j), macroName)) tok.set(j, replacement); |
22 | |
23 | // delete macro declaration |
24 | clearTokens(tok, i, iMacroClosingBracket+1); |
25 | |
26 | reTok(tok, i, end); |
27 | } |
28 | } |
Began life as a copy of #1013759
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032653 |
Snippet name: | tok_localMacro - define a macro local to current block |
Eternal ID of this version: | #1032653/4 |
Text MD5: | 6c82df7d074b6cc02df10aeb046c6f6a |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-30 05:10:59 |
Source code size: | 917 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 155 / 229 |
Version history: | 3 change(s) |
Referenced in: | [show references] |