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

23
LINES

< > BotCompany Repo | #1028812 // jreplaceIC_literal - no "*" etc, just compare the tokens

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

Libraryless. Click here for Pure Java version (2803L/17K).

1  
sS jreplaceIC_literal(S s, S in, S out) {
2  
  LS tokIn = javaTokC(in);
3  
  LS tok = javaTok(s);
4  
  LS tokOut = null;
5  
  int n = l(tok)-l(tokIn)*2+1;
6  
7  
  int i = 1;
8  
  bool change;
9  
  while ping (i < n) {
10  
    ifdef jreplaceIC_literal_debug
11  
      print("jreplaceIC_literal: list=" + subList(tok, i, i+l(tokIn)*2-1));
12  
    endifdef
13  
    if (!codeTokensEqualICAtIndex(tok, tokIn, i))
14  
      continue with i += 2;
15  
    if (tokOut == null) tokOut = dropFirstAndLast(javaTok(out));
16  
    int oldEnd = i+l(tokIn)*2-1, newEnd = i+l(tokOut);
17  
    replaceSublist(tok, i, oldEnd, tokOut);
18  
    n += newEnd-oldEnd;
19  
    i = newEnd+1;
20  
    set change;
21  
  }
22  
  ret change ? join(tok) : s;
23  
}

Author comment

Began life as a copy of #1002133

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1028812
Snippet name: jreplaceIC_literal - no "*" etc, just compare the tokens
Eternal ID of this version: #1028812/17
Text MD5: c57e1cc70306c8608e838bd7514b9851
Transpilation MD5: bb21d055b323e67fc8c757fb806b016a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-09 11:49:03
Source code size: 676 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 180 / 251
Version history: 16 change(s)
Referenced in: [show references]