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.3.0.tbz
sha256=6948979d6ffb5e596773baead81e9ceef36726d6956261bdd62abb2666a45bfc
sha512=db8b39cc9a77d919ab3123bb4047bb6c672c61db9fc6810951e267b2b113c4ac07266ef57188c6db0c02cb4d43d054204cd66ebc91648dbd1da1228022b0e67b

doc/grace/Grace/Source/index.html

Module Grace.SourceSource

Source is a file-like abstraction.

Grace provides the abstraction of a file called a 'source'.

There are several benefits with providing a in-memory abstraction of a sources:

  1. Virtual files: It is often useful to invent temporary files (e.g. test input, command line input, REPL input). By providing a in-memory abstraction, Grace provides the ability to create virtual files.
  1. Caching: Caching sources is useful in many situations (e.g. LSP semantic analysis, reporting multiple errors in a single file in a diagnostic reporter, etc).
Sourcemodule Reader : sig ... end
Sourcetype string_source = {
  1. name : string option;
    (*

    The name of a string source. The diagnostic render can use the name of a string source in place of a file path.

    *)
  2. content : string;
    (*

    The content of a string source

    *)
}

An in-memory string source.

Sourceval sexp_of_string_source : string_source -> Sexplib0.Sexp.t
Sourceval string_source_of_sexp : Sexplib0.Sexp.t -> string_source
Sourcetype t = [
  1. | `File of string
    (*

    A file source specified by its filename.

    *)
  2. | `String of string_source
    (*

    A in-memory string source.

    *)
  3. | `Reader of Reader.t
    (*

    A reader-backed source.

    *)
]

The type of sources.

Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
Sourceval __t_of_sexp__ : Sexplib0.Sexp.t -> t
include Grace_std.Comparable.S with type t := t
Sourceval (>=) : t -> t -> bool
Sourceval (<=) : t -> t -> bool
Sourceval (>) : t -> t -> bool
Sourceval (<) : t -> t -> bool
Sourceval (=) : t -> t -> bool
Sourceval (<>) : t -> t -> bool
Sourceval compare : t -> t -> int
Sourceval equal : t -> t -> bool
Sourceval min : t -> t -> t
Sourceval max : t -> t -> t
Sourceval name : t -> string option

name src returns the name of the source if it exists.

Sourceval length : t -> int

length src returns the length or size in bytes of src. Interpreted as a byte_index, this is known as the end-of-source position.

  • raises Invalid_argument

    if the file size is larger than an OCaml 63-bit integer.