Source line lookup
Maps source offsets to line numbers using a reusable newline index.
The scanner uses this internal helper to attach locations efficiently. Offsets follow JavaScript UTF-16 string indexing, including the documented newline boundary behavior.