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

23
LINES

< > BotCompany Repo | #1033719 // replaceKeywordPlusQuotedBlock_dyn

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

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

1  
scope replaceKeywordPlusQuotedBlock_dyn
2  
3  
sinterface #IReplacer {
4  
  S[] get(LS tok, int iOpening);
5  
}
6  
7  
// finds "<keyword> <quoted> {"
8  
// func: tok, iKeyword -> S[] {beg, end}
9  
static LS replaceKeywordPlusQuotedBlock_dyn(LS tok, S keyword, IReplacer f) {
10  
  for (int i = 0; i < 1000; i++) {
11  
    int idx = jfind(tok, keyword + " <quoted> {");
12  
    if (idx < 0)
13  
      break;
14  
    int j = findEndOfBracketPart(tok, idx+4);
15  
    
16  
    S[] be = f.get(tok, idx);
17  
    tok.set(idx, be[0]);
18  
    clearTokens(tok, idx+1, idx+5);
19  
    tok.set(j-1, be[1]);
20  
    reTok(tok, idx, j);
21  
  }
22  
  ret tok;
23  
}

Author comment

Began life as a copy of #1009010

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033719
Snippet name: replaceKeywordPlusQuotedBlock_dyn
Eternal ID of this version: #1033719/1
Text MD5: e98a9918b7e66e1548a0d14932811b44
Transpilation MD5: df195c9653c72452f707ca98d86656d3
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:41:49
Source code size: 597 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 129 / 186
Referenced in: [show references]