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).

1  
// finds "<keyword> <quoted> {"
2  
// func: tok, C token index of keyword -> S[] {beg, end}
3  
static LS replaceKeywordPlusQuotedBlock(LS tok, S keyword, O func) {
4  
  for (int i = 0; i < 1000; i++) {
5  
    int idx = jfind(tok, keyword + " <quoted> {");
6  
    if (idx < 0)
7  
      break;
8  
    int j = findEndOfBracketPart(tok, idx+4);
9  
    
10  
    S[] be = (S[]) callF(func, tok, idx);
11  
    tok.set(idx, be[0]);
12  
    clearTokens(tok, idx+1, idx+5);
13  
    tok.set(j-1, be[1]);
14  
    reTok(tok, idx, j);
15  
  }
16  
  ret tok;
17  
}

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: 389 / 497
Version history: 5 change(s)
Referenced in: [show references]