Module Conv.Txt
Textual codecs
Textual encoders and decoders
type 'a enc= Stdlib.Format.formatter -> 'a -> unitThe type for textual encoders.
enc ppf vtextually encodes the valuevonppf. RaisesErrorin case of error.
type 'a dec= string -> start:int -> int * 'aThe type for textual decoders.
dec s ~starttextually decodes a value atstartins.startis either the first textual input bytes to consider (which may be whitespace or a commenet) or the length ofs. The function returns(i, v)withvthe decoded value andithe first index after the decoded value or the lenght ofsif there is no such index. RaisesErrorin case of error.XXX. In the end this signature is showing its limits for error reporting. Maybe we should have an abstraction here.
Encoding
val enc_err : kind:string -> ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'aenc_err ~kind fmtraises a textual encoding error message for kindkindformatted according tofmt.
Decoding
val dec_err : kind:string -> int -> ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'adec_err ~kind i fmtraises a textual decoding error message for kindkindat input byte indexiformatted according tofmt.
val dec_err_eoi : kind:string -> int -> 'adec_err_eoi ~kind iraises a textual error message for kindkindat input byte indexiindicating an unexpected end of input.
val dec_err_lexeme : kind:string -> int -> lexeme -> exp:lexeme list -> 'adec_err_case ~kind iraises a textual error message for kindkindat input byte indexiindicating one ofexpwas expected.
val dec_err_atom : kind:string -> int -> string -> exp:string list -> 'adec_err_atom ~kind i a expraises a textual error message for kindkindat input byte indexiand atomaindicating one ofexpatoms was expected.
val dec_skip : kind:string -> string -> start:int -> intdec_skip ~kind s ~startstarting atstart(which can be out of bounds) is the first non-white, non-comment, byte index or the length ofsif there is no such index.
val dec_lexeme : kind:string -> (int * lexeme) decdec_case ~kind s ~startstarting atstart(which can be out of bounds), skips whitespace and comment, looks for either a left parenthesis, right parenthesis or an atom and returns the index of their first position. Errors if end of input is is found.
val dec_ls : kind:string -> string -> start:int -> intdec_ls ~kind s ~startstarting atstart(which can be out of bounds), skips whitespace and comments, parses a list start and returns the index after it or the length ofs.
val dec_le : kind:string -> string -> start:int -> intdec_le ~kind s ~startstarting atstart(which can be out of bounds), skips whitespace and comments, parses a list end and returns the index after it or the length ofs.
val dec_atom : kind:string -> string decdec_atom ~kind s ~startstarting atstart(which can be out of bounds), skips whitespace and comments, parses an atom and returns the index after it or the length ofs.