ifclass ListAndIndex static int tokenToCharIndex(ListAndIndex ptr) { ret ptr == null ? -1 : tokenToCharIndex(ptr.list(), ptr.idx()); } endif static int tokenToCharIndex(LS tok, int tokenIndex) { if (tokenIndex < 0) ret -1; int idx = 0; tokenIndex = min(tokenIndex, l(tok)); for i to tokenIndex: idx += l(tok.get(i)); ret idx; }