B0_text.TextdecText decoder.
A text decoder inputs UTF-8 encoded characters from a string. It checks its validity and maintains information the absolute byte positions and line position (incrementing on LF, CR or CRLF) of the last decoded character. It also has a token buffer that can be used for lexing.
val sot : decodesot is x11_0000 (Uchar.max + 1) an integer to represent the start of text.
val eot : decodeeot is x11_0001 (Uchar.max + 2) an integer to represent the end of text.
val pp_decode : Stdlib.Format.formatter -> decode -> unitval make : ?file:Textloc.filepath -> string -> tmake ~file s decodes UTF-8 text from s assuming to have been read from a file file (defaults to Textloc.file_none).
val input : t -> stringinput d is the input string of d
val file : t -> Textloc.filepathfile d is the file associated to d.
val is_error : t -> boolis_error d is true if current d is Uchar.rep and not the result of a valid UTF-8 decode.
val next : t -> unitval first_byte_pos : t -> Textloc.byte_posval last_byte_pos : t -> Textloc.byte_posval line_num : t -> Textloc.line_numline_num d is the current line number.
val line_start : t -> Textloc.byte_posline_num d is the first byte position on the current line. See Textloc.line_pos.
val line_pos : t -> Textloc.line_posline_pos d is the line position of the current decode.
val prev_line_num : t -> Textloc.line_numprev_line_num d is the previous line number. This is line_num minus one or 1 on the first line.
val prev_line_start : t -> Textloc.byte_posprev_line_start is the line start of the previous line.
val prev_line_pos : t -> Textloc.line_posprevious_line_pos d is the line position of the previous line.
val pos : t -> Textloc.byte_pos * Textloc.line_pospos d is first_byte_pos d, line_pos d. This is the first position of the current decode.
textloc d is the text position of the current decode. The text location spans the UTF-8 bytes of the decode it is on line_pos d.
val textloc_span :
t ->
start:(Textloc.byte_pos * Textloc.line_pos) ->
Textloc.ttextloc_span d ~start is a text location that spans from start to the last byte of the current decode.
val textloc_span_to_prev_decode :
t ->
start:(Textloc.byte_pos * Textloc.line_pos) ->
Textloc.ttextloc_span_to_prev_decode d ~start is a text location that spans from start to the last byte of the previous decode.
val lexeme_clear : t -> unitlexeme_clear d clears the lexeme buffer.
val lexeme_pop : t -> stringlexeme_pop d gets the lexeme buffer contents and clears is.
val lexeme_add : t -> Stdlib.Uchar.t -> unitlexeme_add d u adds the UTF-8 encoding of u to the lexeme buffer.