Libraryless. Click here for Pure Java version (4634L/26K).
ifclass ListAndIndex static LineAndColumn tokenToLineAndColumn(ListAndIndex<S> ptr) { ret ptr == null ?: tokenToLineAndColumn(ptr.list(), ptr.idx()); } endif static LineAndColumn tokenToLineAndColumn(LS tok, int tokenIndex) { int line = 1, col = 1; tokenIndex = min(tokenIndex, l(tok)); for i to tokenIndex: { S t = tok.get(i); int n = l(t); for j to n: if (t.charAt(j) == '\n') { ++line; col = 1; } else ++col; } ret LineAndColumn(line, col); }
Began life as a copy of #1008636
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1033994 |
| Snippet name: | tokenToLineAndColumn |
| Eternal ID of this version: | #1033994/4 |
| Text MD5: | f1bb477b3916e07c0d65a23dc5f05beb |
| Transpilation MD5: | fc06193bcdd40b4a24c397f6369f6694 |
| 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:41 |
| Source code size: | 526 bytes / 21 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 697 / 864 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |