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

11
LINES

< > BotCompany Repo | #1012968 // ai_ifThenToMultiLine - idempotent

JavaX fragment (include)

1  
static S ai_ifThenToMultiLine(S s) {
2  
  s = trim(s);
3  
  if (containsNewLine(s)) ret s;
4  
  L<S> tok = tok_groupRoundBrackets(javaTok(s));
5  
  int i = 2;
6  
  while ((i = indexOfOneOfIC(tok, i, "then", "and")) >= 0) {
7  
    tokPrepend(tok, i, "\n");
8  
    i += 2;
9  
  }
10  
  ret join(tok);
11  
}

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: #1012968
Snippet name: ai_ifThenToMultiLine - idempotent
Eternal ID of this version: #1012968/5
Text MD5: 1bd3d8a55b4fdde7929d15b6f89fade2
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-18 23:33:41
Source code size: 282 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 456 / 485
Version history: 4 change(s)
Referenced in: [show references]