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

22
LINES

< > BotCompany Repo | #1033108 // tok_splitAtAnyOperator [seems to work]

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

Transpiled version (4097L) is out of date.

1  
static LS tok_splitAtAnyOperator(S s) {
2  
  ret tok_splitAtAnyOperator(javaTok(s));
3  
}
4  
5  
static LS tok_splitAtAnyOperator(LS tok) {
6  
  new LS l;
7  
  int i = 1;
8  
  while ping (i < l(tok)) {
9  
    S t;
10  
    int lastI = i, j = i;
11  
    while (l(t = get(tok, j)) == 1 && !startsWithLetterOrDigit(t))
12  
      j += 2;
13  
    addIfNempty(l, trimJoinSubList(tok, i, j));
14  
    i = j;
15  
    while (j < l(tok) && !(l(t = get(tok, j)) == 1 && !startsWithLetterOrDigit(t)))
16  
      j += 2;
17  
    addIfNempty(l, trimJoinSubList(tok, i, j));
18  
    i = j;
19  
    assertTrue("safety", i > lastI);
20  
  }
21  
  ret l;
22  
}

Author comment

Began life as a copy of #1017544

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033108
Snippet name: tok_splitAtAnyOperator [seems to work]
Eternal ID of this version: #1033108/7
Text MD5: c13836a9182c418aa66bb93c651f3c6f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-14 17:11:01
Source code size: 585 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 94 / 155
Version history: 6 change(s)
Referenced in: [show references]