package dolmen

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

Standard implementation of file locations.

Interface definition

type loc = {
  1. file : string;
  2. start_line : int;
  3. start_column : int;
  4. stop_line : int;
  5. stop_column : int;
}

A full location, including file, start position and end position. Dummy positions (i.e. with start_line = stop_line and start_column = stop_column) are allowed to represent unknown locations.

type file

Meta-data about files to enable more compact location storage.

type t

A compact representation of locations.

type full = {
  1. file : file;
  2. loc : t;
}

Interface definition

module type S = Dolmen_intf.Location.S

An anstract module type for providing locations. Used as argumentby much of the functors provided in Dolmen.

This module implements the signature S.

include S with type t := t and type file := file
exception Uncaught of t * exn * Stdlib.Printexc.raw_backtrace

The exception to be raised whenever an unexpected exception is raised during parsing.

exception Lexing_error of t * string

The exception to be raised when the lexer cannot parse the input.

exception Syntax_error of t * [ `Regular of Dolmen_intf.Msg.t | `Advanced of Dolmen_intf.Msg.t * Dolmen_intf.Msg.t * Dolmen_intf.Msg.t ]

Syntax_error (loc, msg) denotes a syntax error at the given location. In the `Advanced (prod, parsed, expected) case,

  • prod is a delayed message to print in order to identify which production/syntax construction the parser was trying to reduce,
  • parsed is a description of the token which raised the error,
  • expected is a messages describing what would have been corect tokens/inputs at that point.
val of_lexbuf : Stdlib.Lexing.lexbuf -> t

Make a position using a lexbuf directly.

val mk_pos : Stdlib.Lexing.position -> Stdlib.Lexing.position -> t

Make a position from two lewing positions.

val newline : file -> Stdlib.Lexing.lexbuf -> unit

Offer a way for the file meta-data to store the current location of the lexbuf as the start of a new line.

val hash : t -> int

Hashing function.

val eq : t -> t -> bool

Location equality.

val no_loc : t

An dummy location pointing at the first byte of a file.

val is_dummy : loc -> bool

Is the location ana ctual location, or a dummy one ?

Compact location handling

val mk_file : string -> file

Create a new set of meta-data for the given filename.

val new_line : file -> int -> unit

Register a new line whose first char is at the given offset.

Compact<->full translations

val loc : file -> t -> loc
val full_loc : full -> loc

Return a complete location from a compact location and meta-data.

val compact : loc -> file * t

Compactify a full location into a compact representation.

Printing locations

val pp : Stdlib.Buffer.t -> loc -> unit
val fmt : Stdlib.Format.formatter -> loc -> unit
val fmt_pos : Stdlib.Format.formatter -> loc -> unit
val fmt_hint : Stdlib.Format.formatter -> loc -> unit

Printing functions

val file_name : file -> string

Filename for a file

OCaml

Innovation. Community. Security.