spanner
Spanner — source code position and span tracking.
Types
pub type Position {
Position(line: Int, column: Int, byte_offset: Int)
}
Constructors
-
Position(line: Int, column: Int, byte_offset: Int)
Values
pub fn advance(position: Position, source: String) -> Position
Advances a position in a source string.
Handles \r\n and \r line endings. Columns count graphemes, so
multi-byte characters like é advance the column by 1.
pub fn between(start start: Position, end end: Position) -> Span
Creates a span between two positions.
pub fn label(filename: String, span: Span) -> String
Formats a position with a filename, e.g. "src/main.gl:3:5".