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

20
LINES

< > BotCompany Repo | #1022527 // tok_forUnnull - now also allows fOr (...)

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

Libraryless. Click here for Pure Java version (3560L/21K).

svoid tok_forUnnull(LS tok) {
  jreplace(tok, "fOr (", "for unnull (");
  
  int i = -1;
  while ((i = jfind(tok, i+1, "for unnull (")) >= 0) {
    int argsFrom = i+4;
    int iColon = indexOf(tok, i, ":");
    int iClosing = tok_findEndOfForExpression(tok, iColon+2);
    ifdef tok_forUnnull_debug
      print("Found for unnull: " + joinSubList(tok, i, iClosing+1));
    endifdef
    clearTokens(tok, i+2, i+4);
    tokPrepend(tok, iColon+2, "unnullForIteration(");
    tokPrepend(tok, iClosing, ")");
    reTok(tok, i+2, iClosing+1);
    ifdef tok_forUnnull_debug
      print("for unnull => " + joinSubList(tok, i, iClosing+1));
    endifdef
  }
}

Author comment

Began life as a copy of #1013206

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022527
Snippet name: tok_forUnnull - now also allows fOr (...)
Eternal ID of this version: #1022527/11
Text MD5: 0f17dfe664f654a355d3febcc0d705c9
Transpilation MD5: 821e9a4a8c47d9459d40b4c507dadd95
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-07 03:43:26
Source code size: 668 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 269 / 328
Version history: 10 change(s)
Referenced in: [show references]