Pure OCaml Yaml 1.2 reader and writer using Bytesrw
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Position tracking for source locations *)
7
8type t = {
9 index : int; (** Byte offset from start *)
10 line : int; (** 1-indexed line number *)
11 column : int; (** 1-indexed column number *)
12}
13
14val initial : t
15(** Initial position (index=0, line=1, column=1) *)
16
17val advance_byte : t -> t
18(** Advance by one byte (increments index and column) *)
19
20val advance_line : t -> t
21(** Advance to next line (increments index and line, resets column to 1) *)
22
23val advance_char : char -> t -> t
24(** Advance by one character, handling newlines appropriately *)
25
26val advance_utf8 : Uchar.t -> t -> t
27(** Advance by one Unicode character, handling newlines and multi-byte characters *)
28
29val advance_bytes : int -> t -> t
30(** Advance by n bytes *)
31
32val pp : Format.formatter -> t -> unit
33(** Pretty-print a position *)
34
35val to_string : t -> string
36(** Convert position to string *)
37
38val compare : t -> t -> int
39(** Compare two positions by index *)
40
41val equal : t -> t -> bool
42(** Test equality of two positions *)