Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1004949 // jreplaceExpandRefs

JavaX fragment (include)

1  
// "$1" is first code token, "$2" second code token etc.
2  
static S jreplaceExpandRefs(S s, L<S> tokref) {
3  
  if (!contains(s, '$')) ret s;
4  
  L<S> tok = javaTok(s);
5  
  for (int i = 1; i < l(tok); i += 2) {
6  
    S t = tok.get(i);
7  
    if (t.startsWith("$") && isInteger(t.substring(1))) {
8  
      S x = tokref.get(-1+parseInt(t.substring(1))*2);
9  
      tok.set(i, x);
10  
    } else if (t.equals("\\")) {
11  
      tok.set(i, "");
12  
      i += 2;
13  
    }
14  
  }
15  
  ret join(tok);
16  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1004949
Snippet name: jreplaceExpandRefs
Eternal ID of this version: #1004949/7
Text MD5: 0d8daac63bcd0efafa485afeba5991b1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-23 15:55:20
Source code size: 472 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 530 / 842
Version history: 6 change(s)
Referenced in: [show references]