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

17
LINES

< > BotCompany Repo | #1008628 // tok_javaDropCommentsFromWhitespace

JavaX fragment (include)

1  
static S tok_javaDropCommentsFromWhitespace(S s) {
2  
  int l = l(s), j = 0;
3  
  new StringBuilder buf;
4  
  while (j < l) {
5  
    char c = s.charAt(j);
6  
    char d = j+1 >= l ? '\0' : s.charAt(j+1);
7  
    if (c == '/' && d == '*') {
8  
      do ++j; while (j < l && !s.substring(j, Math.min(j+2, l)).equals("*/"));
9  
      j = Math.min(j+2, l);
10  
    } else if (c == '/' && d == '/') {
11  
      do ++j; while (j < l && "\r\n".indexOf(s.charAt(j)) < 0);
12  
    } else {
13  
      buf.append(c); ++j;
14  
    }
15  
  }
16  
  ret str(buf);
17  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1008628
Snippet name: tok_javaDropCommentsFromWhitespace
Eternal ID of this version: #1008628/1
Text MD5: 5da89915f1839958ee2bac02d84feead
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-26 14:50:28
Source code size: 513 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 532 / 724
Referenced in: [show references]