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

17
LINES

< > BotCompany Repo | #1025503 // replaceKeywordPlusQuotedOrIDBlock

JavaX fragment (include)

// finds "<keyword> <quoted> {" and "<keyword> <id> {"
// func: tok, C token index of keyword -> S[] {beg, end}
static L<S> replaceKeywordPlusQuotedOrIDBlock(L<S> tok, S keyword, O func) {
  for (int i = 0; i < 1000; i++) {
    int idx = jfind_any(tok, keyword + " <quoted> {", keyword + " <id> {");
    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 #1009010

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025503
Snippet name: replaceKeywordPlusQuotedOrIDBlock
Eternal ID of this version: #1025503/1
Text MD5: 3bea929595cf695abffe95cd6f6da969
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-01 15:19:23
Source code size: 565 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 153 / 182
Referenced in: [show references]