yamleam/position

Source position tracking.

Position points at a single character in the source. Both fields are 1-indexed so error messages match editor conventions (line 1 is the first line, column 1 is the first character of a line).

Types

pub type Position {
  Position(line: Int, column: Int)
}

Constructors

  • Position(line: Int, column: Int)

Values

pub fn advance(pos: Position, char: String) -> Position

Advance the position by one character, handling newline wrap-around.

pub fn start() -> Position

The position of the first character of any source string.

Search Document