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

13
LINES

< > BotCompany Repo | #1024308 - tlftj_honoringBrackets - like tlfj, but keeps bracket-enclosed lines together

JavaX fragment (include)

static LS tlftj_honoringBrackets(S s) {
  LS tok = javaTokWithBrackets(javaDropComments(s));
  new LS out;
  int j = 1;
  for (int i = 2; i+1 < l(tok); i += 2)
    if (containsNewLine(tok.get(i))) {
      addIfNempty(out, joinSubList(tok, j, i));
      j = i+1;
    }
  if (j < l(tok)-1)
    addIfNempty(out, joinSubList(tok, j, l(tok)-1));
  ret out;
}

download  show line numbers  debug dex   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz

No comments. add comment

Snippet ID: #1024308
Snippet name: tlftj_honoringBrackets - like tlfj, but keeps bracket-enclosed lines together
Eternal ID of this version: #1024308/7
Text MD5: 5993b2f65d62c60567d9f9513b5952d6
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-31 01:32:37
Source code size: 365 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 48 / 75
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1024308 & http://1024308.tinybrain.de