1 | static S structure_addTokenMarkers(S s) { |
2 | ret join(structure_addTokenMarkers(javaTokForStructure(s))); |
3 | } |
4 | |
5 | static L<S> structure_addTokenMarkers(L<S> tok) { |
6 | // find references |
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 | } |
14 | |
15 | if (empty(refs)) ret tok; |
16 | |
17 | // add markers |
18 | for (int i : refs) { |
19 | int idx = i*2+1; |
20 | if (idx >= l(tok)) continue; // broken structure |
21 | S t = ""; |
22 | if (endsWithLetterOrDigit(tok.get(idx-1))) t = " "; |
23 | tok.set(idx, t + "m" + i + " " + tok.get(idx)); |
24 | } |
25 | |
26 | ret tok; |
27 | } |
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1010235 |
Snippet name: | structure_addTokenMarkers - add token markers ("m123" matching "t123") to structure for easier readability. Use structure_convertTokenMarkersToExplicit instead, it allows unstructuring |
Eternal ID of this version: | #1010235/14 |
Text MD5: | 98028cf6145ba4cce9edc9ec0123aa89 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-03-31 14:33:37 |
Source code size: | 688 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 655 / 771 |
Version history: | 13 change(s) |
Referenced in: | [show references] |