Skip to main content

Module line_map

Module line_map 

Source
Expand description

Line/column mapping for a source file.

LineMap precomputes the byte offset at the start of each line so that BytePosLineCol conversion is a binary search, not a rescan. All offsets are byte offsets (§4.1: source is UTF-8); a column is the byte offset from the start of the line, so multi-byte characters occupy more than one column. This keeps the mapping lossless and O(1) to invert.

Structs§

LineCol
A 1-based (line, column) position. line starts at 1, col is the byte offset from the line start (so the first byte of a line is column 0).
LineMap
A precomputed table of line-start byte offsets for a single source file.