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

31
LINES

< > BotCompany Repo | #1003367 // reTok - javaTok in place

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

Libraryless. Click here for Pure Java version (2371L/15K).

1  
static L<S> reTok(L<S> tok) {
2  
  replaceCollection(tok, javaTok(tok));
3  
  ret tok;
4  
}
5  
6  
static L<S> reTok(L<S> tok, int i) {
7  
  ret reTok(tok, i, i+1);
8  
}
9  
10  
static L<S> reTok(L<S> tok, int i, int j) {
11  
  // extend i to an "N" token
12  
  // and j to "C" (so j-1 is an "N" token)
13  
  i = max(i & ~1, 0);
14  
  j = min(l(tok), j | 1);
15  
  if (i >= j) ret tok;
16  
  
17  
  L<S> t = javaTok(joinSubList(tok, i, j));
18  
  replaceListPart(tok, i, j, t);
19  
  
20  
  // fallback to safety
21  
  // reTok(tok);
22  
  
23  
  ret tok;
24  
}
25  
26  
ifclass IntRange
27  
static LS reTok(LS tok, IntRange r) {
28  
  if (r != null) reTok(tok, r.start, r.end);
29  
  ret tok;
30  
}
31  
endif

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: #1003367
Snippet name: reTok - javaTok in place
Eternal ID of this version: #1003367/5
Text MD5: 5552a621749e3d47541e1217e4224323
Transpilation MD5: 73907893760070d3de32ff589fa89b21
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-28 22:26:28
Source code size: 627 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 761 / 1478
Version history: 4 change(s)
Referenced in: [show references]