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

17
LINES

< > BotCompany Repo | #1021422 // javaTokNPunctuation_bracketsInC - put words + curly & round brackets in C, punctuation + spacing in N

JavaX fragment (include)

static L<S> javaTokNPunctuation_bracketsInC(S s) {
  L<S> tok = javaTok(s);
  for (int i = 1; i < l(tok); i += 2) {
    int j = i;
    S t;
    char c;
    while (j < l(tok)
      && l(t = tok.get(j)) == 1
      && !Character.isLetterOrDigit(c = t.charAt(0))
      && "{}()".indexOf(c) < 0)
        j += 2;
    if (j > i)
      // j points to next C token after mergeable stuff
      replaceSubList(tok, i-1, j, ll(joinSubList(tok, i-1, j)));
  }
  ret tok;
}

Author comment

Began life as a copy of #1017442

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: #1021422
Snippet name: javaTokNPunctuation_bracketsInC - put words + curly & round brackets in C, punctuation + spacing in N
Eternal ID of this version: #1021422/3
Text MD5: 8328c5caa2bfd46e92bdb3790d645cda
Author: stefan
Category: javax / tokenizing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-11 16:43:20
Source code size: 475 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 323 / 363
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)