1 | // TODO: ignore N tokens |
2 | static LS tok_groupPhrase(LS tok, S phrase) { |
3 | LS tokPhrase = dropFirstAndLast(javaTok_cached(phrase)); |
4 | L<Int> l = indicesOfSubListIC(tok, tokPhrase); |
5 | for (int i : l) { |
6 | int j = i+l(tokPhrase)-1; |
7 | if (i == 1 && j == l(tok)-2) continue; |
8 | S pre = get(tok, i-1), post = get(tok, j+1); |
9 | if (endsWith(pre, "{") && startsWith(post, "}")) |
10 | continue; |
11 | tokPrepend(tok, i, "{"); |
12 | tokAppend(tok, j, "}"); |
13 | } |
14 | ret tok; |
15 | } |
16 | |
17 | sS tok_groupPhrase(S s, S phrase) { |
18 | ret join(tok_groupPhrase(javaTok(s), phrase)); |
19 | } |
Began life as a copy of #1018199
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1021553 |
Snippet name: | tok_groupPhrase |
Eternal ID of this version: | #1021553/13 |
Text MD5: | 15f4035b1d9fc730f960c126f389e62c |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-09 14:24:07 |
Source code size: | 569 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 346 / 374 |
Version history: | 12 change(s) |
Referenced in: | [show references] |