Pure OCaml Yaml 1.2 reader and writer using Bytesrw
at main 1.4 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** YAML token types produced by the scanner *) 7 8type t = 9 | Stream_start of Encoding.t 10 | Stream_end 11 | Version_directive of { major : int; minor : int } 12 | Tag_directive of { handle : string; prefix : string } 13 | Document_start (** --- *) 14 | Document_end (** ... *) 15 | Block_sequence_start 16 | Block_mapping_start 17 | Block_entry (** - *) 18 | Block_end (** implicit, from dedent *) 19 | Flow_sequence_start (** \[ *) 20 | Flow_sequence_end (** \] *) 21 | Flow_mapping_start (** \{ *) 22 | Flow_mapping_end (** \} *) 23 | Flow_entry (** , *) 24 | Key (** ? or implicit key *) 25 | Value (** : *) 26 | Anchor of string (** &name *) 27 | Alias of string (** *name *) 28 | Tag of { handle : string; suffix : string } 29 | Scalar of { style : Scalar_style.t; value : string } 30 31type spanned = { 32 token : t; 33 span : Span.t; 34} 35 36val pp_token : Format.formatter -> t -> unit 37(** Pretty-print a token *) 38 39val pp : Format.formatter -> t -> unit 40(** Pretty-print a token (alias for pp_token) *) 41 42val pp_spanned : Format.formatter -> spanned -> unit 43(** Pretty-print a spanned token *)