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

15
LINES

< > BotCompany Repo | #1007459 // tok_groupRoundBrackets (keeps the brackets too)

JavaX fragment (include)

static L<S> tok_groupRoundBrackets(S s) {
  ret tok_groupRoundBrackets(javaTok(s));
}
  
static L<S> tok_groupRoundBrackets(L<S> tok) {
  while true {
    int i = tok.lastIndexOf("(");
    if (i < 0) ret tok;
    int j = indexOf(tok, ")", i);
    if (j < 0) ret tok;
    tok.set(i, join(subList(tok, i, j+1)));
    tok.subList(i+1, j+1).clear();
    assertTrue(odd(l(tok)));
  }
}

Author comment

Began life as a copy of #1007458

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007459
Snippet name: tok_groupRoundBrackets (keeps the brackets too)
Eternal ID of this version: #1007459/3
Text MD5: e012326b2d4e6d523287eb63f1c66409
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-11 14:43:28
Source code size: 394 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 448 / 487
Version history: 2 change(s)
Referenced in: [show references]