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

16
LINES

< > BotCompany Repo | #1004949 - jreplaceExpandRefs

JavaX fragment (include)

// "$1" is first code token, "$2" second code token etc.
static S jreplaceExpandRefs(S s, L<S> tokref) {
  if (!contains(s, '$')) ret s;
  L<S> tok = javaTok(s);
  for (int i = 1; i < l(tok); i += 2) {
    S t = tok.get(i);
    if (t.startsWith("$") && isInteger(t.substring(1))) {
      S x = tokref.get(-1+parseInt(t.substring(1))*2);
      tok.set(i, x);
    } else if (t.equals("\\")) {
      tok.set(i, "");
      i += 2;
    }
  }
  ret join(tok);
}

download  show line numbers  debug dex   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, 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: 331 / 619
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1004949 & http://1004949.tinybrain.de