package asai

  1. Overview
  2. Docs

Making an explicator.

Parameters

module _ : Reader
module Style : Style

Signature

exception Unexpected_end_of_file of Span.position

Unexpected_end_of_file pos means the pos lies beyond the end of file. This usually means the file has been truncated after the parsing.

exception Unexpected_line_num_increment of Span.position

Unexpected_line_num_increment pos means the line number of pos is larger than than that of its preceding position during explication, but the explicator did not encounter a newline in between. This usually indicates that there's something wrong with the lexer, or that the file has changed since the parsing.

exception Unexpected_newline of Span.position

Unexpected_newline pos means the line number of pos is the same as its preceding position during explication, but the explicator encountered a newline in between. This usually indicates that there's something wrong with the lexer, or that the file has changed since the parsing.

exception Unexpected_position_in_newline of Span.position

Unexpected_position_in_newline pos means the position pos is in the middle of a newline. This can happen when the newline consists of multiple bytes, for example 0x0D 0x0A. It usually indicates that there's something wrong with the lexer, or that the file has changed since the parsing.

val explicate : ?line_breaking:[ `Unicode | `Traditional ] -> ?block_splitting_threshold:int -> (Span.t, Style.t) Explication.styled list -> Style.t Explication.t

Explicate a list of spans using content from a data reader.

  • parameter line_breaking

    The algorithm to recognize (hard) line breaks. The `Unicode algorithm recognizes all Unicode character sequences in Unicode 15.0.0 Table 5-1 as line breaks. The `Traditional algorithm only recognizes U+000A (LF), U+000D (CR), and U+000D U+000A (CRLF) as line breaks. The default is the `Traditional algorithm.

  • parameter block_splitting_threshold

    The maximum number of consecutive, non-highlighted lines allowed in a block. The function will try to minimize the number of blocks, as long as no block has too many consecutive, non-highlighted lines. A higher threshold will lead to fewer blocks. When the threshold is zero, it means no block can contain any non-highlighted line. The default value is zero.

  • raises UnexpectedLineNumIncrement

    if the line number of some position is increased by one but there was no newline character \n.

  • raises PositionBeyondEndOfFile

    if some position falls outside the data content. (That is, the file is too smaller, if the data reader is reading files.)

OCaml

Innovation. Community. Security.