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

17
LINES

< > BotCompany Repo | #1018806 // replaceKeywordBlock_dyn2

JavaX fragment (include)

// func : func(LS tok, int iOpening, int iClosing) -> S[] {beg, end}
static L<S> replaceKeywordBlock_dyn2(L<S> tok, S keyword, F3<LS, Int, Int, S[]> func) {
  for (int i = 0; i < 1000; i++) {
    int idx = findCodeTokens(tok, keyword, "{");
    if (idx < 0)
      break;
    int j = findEndOfBracketPart(tok, idx+2);
    
    S[] be = (S[]) callF(func, tok, idx+2, j-1);
    tok.set(idx, be[0]);
    tok.set(idx+1, " ");
    tok.set(idx+2, "");
    tok.set(j-1, be[1]);
    reTok(tok, idx, j);
  }
  ret tok;
}

Author comment

Began life as a copy of #1003848

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018806
Snippet name: replaceKeywordBlock_dyn2
Eternal ID of this version: #1018806/4
Text MD5: 49bae998e303b450c04adf45dd4c1d01
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-13 20:46:32
Source code size: 526 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 369 / 408
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018808 - replaceKeywordBlock_dyn2_legacy - avoid syntax problem with func and many parameters
#1031419 - replaceKeywordBlock_dyn - finally the interface version we all want