package dolmen

All checked builds pass
  1. Overview
  2. Docs
A parser library for automated deduction

Install

dune-project
 Dependency

Authors

Maintainers

Sources

dolmen-0.11.tbz
sha256=235c78a1f4dabc6c116d3d1cf51af286cb3fbed713c6116cd5d1b1cbed0cc87f
sha512=a5ca97d43a2e5ef2b03f5731e48cbfe9f09d7824e5839a9a614ca17d50ba71836b8d45b494f58df2566cf5e1983dad5fd75a3ce75f2c0fc5a9572f7ff4d97d2f

doc/dolmen.std/Dolmen_std/Loc/index.html

Module Dolmen_std.LocSource

Standard implementation of file locations.

Interface definition

Sourcetype loc = private {
  1. file : string;
  2. start_line : int;
  3. start_column : int;
  4. start_line_offset : int;
  5. stop_line : int;
  6. stop_column : int;
  7. stop_line_offset : int;
  8. max_line_length : 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.

Sourcetype file

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

Sourcetype t

A compact representation of locations.

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

Interface definition

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
Sourceexception Uncaught of t * exn * Printexc.raw_backtrace

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

Sourceexception Lexing_error of t * string option * string

The exception to be raised when the lexer cannot parse the input. It contains (in order) the location, the context (if any), and then the string that could not be lexed.

Sourceexception Syntax_error of t * [ `Regular of Dolmen_intf.Msg.t | `Advanced of string * 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 (error_ref, prod, parsed, expected) case,

  • error_ref is an identifier for the error state
  • 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.
Sourceval of_lexbuf : Lexing.lexbuf -> t

Make a position using a lexbuf directly.

Make a position from two lewing positions.

Sourceval newline : file -> 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.

Sourceval update_size : file -> Lexing.lexbuf -> unit

Update the file meta-data to store the maximum offset currently seen for this file.

Sourceval hash : t -> int

Hashing function.

Sourceval eq : t -> t -> bool

Location equality.

Sourceval compare : t -> t -> int

Comparision.

Sourceval no_loc : t

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

Sourceval dummy : loc

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

Sourceval is_dummy : loc -> bool

Is the location an actual location, or a dummy one ?

Compact location handling

Sourceval mk_file : string -> file

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

Sourceval new_line : file -> int -> unit

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

Compact<->full translations

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

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

Sourceval compact : file -> loc -> t

Compactify a full location into a compact representation.

Sourceval lexing_positions : loc -> Lexing.position * Lexing.position

Return the pair of lexing positions corresponding to a location.

Printing locations

Sourceval pp : Buffer.t -> loc -> unit
Sourceval fmt : Format.formatter -> loc -> unit
Sourceval fmt_pos : Format.formatter -> loc -> unit
Sourceval fmt_hint : Format.formatter -> loc -> unit
Sourceval fmt_compact : Format.formatter -> loc -> unit

Printing functions

Sourceval print_compact : Format.formatter -> t -> unit

misc

Sourceval file_name : file -> string

Filename for a file