package grace

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Grace_source_readerSource

A source reader maintains a global table mapping source descriptors to their contents and their line starts.

Sourcemodule Source_descr : sig ... end

A source descriptor is a handle for an open source

Sourcemodule Line_starts : sig ... end
Sourcetype error = [
  1. | `Already_initialized
  2. | `Not_initialized
]
Sourceexception Error of error
Sourceval init : ?line_starts_fn:Line_starts.fn -> unit -> unit

init () initializes the global source reader table.

  • parameter line_starts_fn

    the line starts function used for computing line starts.

  • raises Source_reader.Error

    if the reader is already initialized.

Sourceval clear : unit -> unit

clear () clears the global source reader table.

Sourceval with_reader : ?line_starts_fn:Line_starts.fn -> (unit -> 'a) -> 'a

with_reader f runs f with an initialized reader table, clearing it once f returns.

  • parameter line_starts_fn

    the line starts function used for computing line starts.

  • raises Source_reader.Error

    if the reader is already initialized.

open_source src opens the source, returning its descriptor.

  • raises Source_reader.Error

    if the reader is not initialized.

Sourceval line_starts : Source_descr.t -> Line_starts.t

line_starts sd returns the (possibly cached) line starts of the source sd.

  • raises Source_reader.Error

    if the reader is not initialized.

Sourceval length : Source_descr.t -> int

length sd returns the length or size in bytes of src.

It is semantically equivalent to Source.length src.

Sourceval unsafe_get : Source_descr.t -> int -> char

unsafe_get sd i reads the ith byte of the source without performing any bounds checks on i.

Sourceval slice : Source_descr.t -> Grace.Range.t -> string

slice sd range reads the slice of bytes defined by range.

  • raises Invalid_argment

    if the source descriptor's underlying source is not equal to the range's source.

Sourcemodule Line : sig ... end

lines sd returns an iterator over lines in source sd.

Sourceval lines_in_range : Source_descr.t -> Grace.Range.t -> Line.t Iter.t

lines_in_range sd range returns an iterator over lines in the range in sd.

  • raises Invalid_argment

    if the source descriptor's underlying source is not equal to the line range's source.

OCaml

Innovation. Community. Security.