Libraryless. Click here for Pure Java version (85L/1K).
1 | static List<String> javaTok_noCommentsNoStrings(String s) { |
2 | new ArrayList<S> tok; |
3 | int l = s == null ? 0 : s.length(); |
4 | |
5 | int i = 0, n = 0; |
6 | while (i < l) { |
7 | int j = i; |
8 | char c, d; |
9 | |
10 | // scan for whitespace |
11 | while (j < l) { |
12 | c = s.charAt(j); |
13 | d = j+1 >= l ? '\0' : s.charAt(j+1); |
14 | if (c == ' ' || c == '\t' || c == '\r' || c == '\n') |
15 | ++j; |
16 | else |
17 | break; |
18 | } |
19 | |
20 | tok.add(javaTok_substringN(s, i, j)); |
21 | ++n; |
22 | i = j; |
23 | if (i >= l) break; |
24 | c = s.charAt(i); |
25 | d = i+1 >= l ? '\0' : s.charAt(i+1); |
26 | |
27 | // scan for non-whitespace |
28 | |
29 | if (Character.isJavaIdentifierStart(c)) |
30 | do ++j; while (j < l && (Character.isJavaIdentifierPart(s.charAt(j)) || "'".indexOf(s.charAt(j)) >= 0)); // for stuff like "don't" |
31 | else if (Character.isDigit(c)) { |
32 | do ++j; while (j < l && Character.isDigit(s.charAt(j))); |
33 | if (j < l && s.charAt(j) == 'L') ++j; // Long constants like 1L |
34 | } else |
35 | ++j; |
36 | |
37 | tok.add(javaTok_substringC(s, i, j)); |
38 | ++n; |
39 | i = j; |
40 | } |
41 | |
42 | if ((tok.size() % 2) == 0) tok.add(""); |
43 | ret tok; |
44 | } |
Began life as a copy of #1000688
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023688 |
Snippet name: | javaTok_noCommentsNoStrings |
Eternal ID of this version: | #1023688/1 |
Text MD5: | e181e869e55d0fdc1e9e441c1a4d03a5 |
Transpilation MD5: | 6b2cbb2688107c2ad528c52d51a6b65e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-07-02 20:28:07 |
Source code size: | 1150 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 310 / 379 |
Referenced in: | [show references] |