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).

sS jreplaceIC_literal(S s, S in, S out) {
  LS tokIn = javaTokC(in);
  LS tok = javaTok(s);
  LS tokOut = null;
  int n = l(tok)-l(tokIn)*2+1;

  int i = 1;
  bool change;
  while ping (i < n) {
    ifdef jreplaceIC_literal_debug
      print("jreplaceIC_literal: list=" + subList(tok, i, i+l(tokIn)*2-1));
    endifdef
    if (!codeTokensEqualICAtIndex(tok, tokIn, i))
      continue with i += 2;
    if (tokOut == null) tokOut = dropFirstAndLast(javaTok(out));
    int oldEnd = i+l(tokIn)*2-1, newEnd = i+l(tokOut);
    replaceSublist(tok, i, oldEnd, tokOut);
    n += newEnd-oldEnd;
    i = newEnd+1;
    set change;
  }
  ret change ? join(tok) : s;
}

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: 255 / 349
Version history: 16 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)