1 | static L<S> htmlFineTok(S s) { |
2 | new L<S> tok; |
3 | int l = 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(quickSubstring(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 (c == '\'' || c == '"') { |
30 | char opener = c; |
31 | ++j; |
32 | while (j < l) { |
33 | if (s.charAt(j) == opener /*|| s.charAt(j) == '\n'*/) { // allow multi-line strings |
34 | ++j; |
35 | break; |
36 | } else if (s.charAt(j) == '\\' && j+1 < l) |
37 | j += 2; |
38 | else |
39 | ++j; |
40 | } |
41 | } else if (Character.isJavaIdentifierStart(c)) |
42 | do ++j; while (j < l && (Character.isJavaIdentifierPart(s.charAt(j)) || "'".indexOf(s.charAt(j)) >= 0)); // for stuff like "don't" |
43 | else if (Character.isDigit(c)) { |
44 | do ++j; while (j < l && Character.isDigit(s.charAt(j))); |
45 | if (j < l && s.charAt(j) == 'L') ++j; // Long constants like 1L |
46 | } else |
47 | ++j; |
48 | |
49 | tok.add(quickSubstring(s, i, j)); |
50 | ++n; |
51 | i = j; |
52 | } |
53 | |
54 | if ((tok.size() % 2) == 0) tok.add(""); |
55 | ret tok; |
56 | } |
Began life as a copy of #1000688
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011293 |
Snippet name: | htmlFineTok |
Eternal ID of this version: | #1011293/4 |
Text MD5: | 4b75d5367d7480999d50cb8e908191f8 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-05 11:57:18 |
Source code size: | 1426 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 483 / 506 |
Version history: | 3 change(s) |
Referenced in: | [show references] |