ifclass ListAndIndex static LineAndColumn tokenToLineAndColumn(ListAndIndex 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); }