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

17
LINES

< > BotCompany Repo | #1009010 // replaceKeywordPlusQuotedBlock

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5265L/30K).

// finds "<keyword> <quoted> {"
// func: tok, C token index of keyword -> S[] {beg, end}
static LS replaceKeywordPlusQuotedBlock(LS tok, S keyword, O func) {
  for (int i = 0; i < 1000; i++) {
    int idx = jfind(tok, keyword + " <quoted> {");
    if (idx < 0)
      break;
    int j = findEndOfBracketPart(tok, idx+4);
    
    S[] be = (S[]) callF(func, tok, idx);
    tok.set(idx, be[0]);
    clearTokens(tok, idx+1, idx+5);
    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, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009010
Snippet name: replaceKeywordPlusQuotedBlock
Eternal ID of this version: #1009010/6
Text MD5: d23cb7d17b187606945a933168aee34a
Transpilation MD5: be5fa934efd44e9f1aded56994fb4854
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-28 20:40:13
Source code size: 509 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 464 / 607
Version history: 5 change(s)
Referenced in: [show references]