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

17
LINES

< > BotCompany Repo | #1009010 - replaceKeywordPlusQuotedBlock

JavaX fragment (include)

// finds "<keyword> <quoted> {"
// func: tok, C token index of keyword -> S[] {beg, end}
static L<S> replaceKeywordPlusQuotedBlock(L<S> 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   

Travelled to 9 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1009010
Snippet name: replaceKeywordPlusQuotedBlock
Eternal ID of this version: #1009010/3
Text MD5: 9200950b091816e034664e6bcdece6ee
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-28 15:43:41
Source code size: 513 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 191 / 247
Version history: 2 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1009010 & http://1009010.tinybrain.de