positioned
Types
A position in a source file, represented by the file name, index, line, and column. The line number starts at 1, the column number starts at 1, and the index starts at 0.
pub type Position {
Position(file: String, index: Int, line: Int, column: Int)
}
Constructors
-
Position(file: String, index: Int, line: Int, column: Int)
Values
pub fn advance(self: Position, token: String) -> Position
Advance the position by a given token, updating the index, line, and column accordingly.
pub fn map(
self: Positioned(a),
transform: fn(a) -> b,
) -> Positioned(b)
Map a function over the value of the positioned value, preserving the position information.
pub fn render(self: Positioned(a), content: String) -> String
Render the span of the positioned value in the source file, highlighting the relevant lines and columns.