Libraryless. Click here for Pure Java version (4612L/26K).
1 | ifclass ListAndIndex |
2 | static int tokenToCharIndex(ListAndIndex<S> ptr) {
|
3 | ret ptr == null ? -1 : tokenToCharIndex(ptr.list(), ptr.idx()); |
4 | } |
5 | endif |
6 | |
7 | static int tokenToCharIndex(LS tok, int tokenIndex) {
|
8 | if (tokenIndex < 0) ret -1; |
9 | int idx = 0; |
10 | tokenIndex = min(tokenIndex, l(tok)); |
11 | for i to tokenIndex: idx += l(tok.get(i)); |
12 | ret idx; |
13 | } |
Began life as a copy of #1008633
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: | #1008636 |
| Snippet name: | tokenToCharIndex |
| Eternal ID of this version: | #1008636/5 |
| Text MD5: | 75eed022ff490397042e48f651197859 |
| Transpilation MD5: | e60cff8d4a031d5513033f296e0d042e |
| Author: | stefan |
| Category: | javax / parsing |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-01-15 20:20:57 |
| Source code size: | 355 bytes / 13 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 814 / 956 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |