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(** YAML tokenizer/scanner with lookahead for ambiguity resolution *)
7
8type t
9
10(** {2 Constructors} *)
11
12val of_string : string -> t
13(** Create scanner from a string *)
14
15val of_input : Input.t -> t
16(** Create scanner from an input source *)
17
18val of_reader : Bytesrw.Bytes.Reader.t -> t
19(** Create scanner from a Bytes.Reader *)
20
21(** {2 Position} *)
22
23val position : t -> Position.t
24(** Get current position in input *)
25
26(** {2 Token Access} *)
27
28val next : t -> Token.spanned option
29(** Get next token *)
30
31val peek : t -> Token.spanned option
32(** Peek at next token without consuming *)
33
34(** {2 Iteration} *)
35
36val iter : (Token.spanned -> unit) -> t -> unit
37(** Iterate over all tokens *)
38
39val fold : ('a -> Token.spanned -> 'a) -> 'a -> t -> 'a
40(** Fold over all tokens *)
41
42val to_list : t -> Token.spanned list
43(** Convert to list of tokens *)