package grace

  1. Overview
  2. Docs
A fancy diagnostics library that allows your compilers to exit with grace

Install

dune-project
 Dependency

Authors

Maintainers

Sources

grace-0.4.1.tbz
sha256=d49754224206de44855590848b3a5a6cc1d5c46cf99a4e5810ca3041d436a28e
sha512=2984b5a6284bf8bbd05419cf850c15c34bc19c19f0c8928b83cc1be1c0bfc84aafef6d992e7435c2f48ba361a6f3aab679abd02f0e6472361c8cec7d497bc405

doc/grace.source_reader/Grace_source_reader/index.html

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.