Tokenize with positions

Write codeMedium30 minStripe style

Your task

Tokenize source text while tracking source positions for error reporting. Given a string, emit one token per maximal run of either word characters ([A-Za-z0-9_]) or punctuation that is a single non-space, non-word character. Whitespace (spaces, tabs, newlines) separates tokens and is not emitted, but advances position. For each token return [text, line, col] where line is 1-based (incremented by '\n') and col is the 1-based column of the token's first character (column resets to 1 after each newline). Return the list of [text, line, col].

Examples

tokenize_pos(src: str) -> list[list]
Example 1
Inputtokenize_pos("ab c\nd")
Output[["ab", 1, 1], ["c", 1, 4], ["d", 2, 1]]