Transpiled version (82L) is out of date.
1 | static LS hashRefTok(S s) { |
2 | new ArrayList<S> tok; |
3 | int l = s == null ? 0 : s.length(); |
4 | |
5 | int i = 0; |
6 | while (i < l) { |
7 | int j = i; |
8 | char c; |
9 | |
10 | // scan for whitespace |
11 | while (j < l) { |
12 | if (j < l-1 && s.charAt(j) == '#') { |
13 | c = s.charAt(j+1); |
14 | if (Character.isJavaIdentifierStart(c) |
15 | || Character.isDigit(c) |
16 | || c == '(') |
17 | break; |
18 | } |
19 | j++; |
20 | } |
21 | |
22 | tok.add(quickSubstring(s, i, j)); |
23 | i = j; |
24 | if (i >= l) break; |
25 | |
26 | // scan for non-whitespace |
27 | |
28 | j = i+1; // skip # |
29 | c = s.charAt(j); |
30 | |
31 | if (Character.isJavaIdentifierStart(c)) { |
32 | do ++j; while (j < l && Character.isJavaIdentifierPart(s.charAt(j))); |
33 | } else if (Character.isDigit(c)) { |
34 | do ++j; while (j < l && Character.isDigit(s.charAt(j))); |
35 | } else if (c == '(') { |
36 | do ++j; while (j < l && s.charAt(j) != ')'); |
37 | j = Math.min(j+1, l); |
38 | } else |
39 | ++j; // not needed but added for safety |
40 | |
41 | tok.add(quickSubstring(s, i, j)); |
42 | i = j; |
43 | } |
44 | |
45 | if ((tok.size() & 1) == 0) tok.add(""); |
46 | ret tok; |
47 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034698 |
Snippet name: | hashRefTok - parses #<int>, #<id> and #(...) references (for Gazelle 22 project stories) |
Eternal ID of this version: | #1034698/4 |
Text MD5: | a170c1908b73c3e29a125c5f7c680dc5 |
Author: | stefan |
Category: | javax / tokenizing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-05 21:08:01 |
Source code size: | 1130 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 148 / 230 |
Version history: | 3 change(s) |
Referenced in: | [show references] |