Libraryless. Click here for Pure Java version (2832L/17K).
1 | sS structure_convertTokenMarkersToExplicit(S s) { |
2 | ret join(structure_convertTokenMarkersToExplicit(javaTokForStructure(s))); |
3 | } |
4 | |
5 | static LS structure_convertTokenMarkersToExplicit(LS tok) { |
6 | // find references & convert to explicit |
7 | |
8 | new TreeSet<Int> refs; |
9 | for (int i = 1; i < l(tok); i += 2) { |
10 | S t = tok.get(i); |
11 | if (t.startsWith("t") && isInteger(t.substring(1))) { |
12 | refs.add(parseInt(t.substring(1))); |
13 | tok.set(i, "r" + substring(t, 1)); |
14 | } |
15 | } |
16 | |
17 | if (empty(refs)) ret tok; |
18 | |
19 | // add markers |
20 | for (int i : refs) { |
21 | int idx = i*2+1; |
22 | if (idx >= l(tok)) continue; // broken structure |
23 | S t = ""; |
24 | if (endsWithLetterOrDigit(tok.get(idx-1))) t = " "; |
25 | tok.set(idx, t + "m" + i + " " + tok.get(idx)); |
26 | } |
27 | |
28 | ret tok; |
29 | } |
Began life as a copy of #1010235
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030716 |
Snippet name: | structure_convertTokenMarkersToExplicit |
Eternal ID of this version: | #1030716/2 |
Text MD5: | b3a1ad3eec1752ff1f242ff007418429 |
Transpilation MD5: | 22939e97254901ad0435ae59f8c3731f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-03-16 16:12:13 |
Source code size: | 793 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 177 / 249 |
Version history: | 1 change(s) |
Referenced in: | [show references] |