package pp_loc

  1. Overview
  2. Docs
Quote and highlight input fragments at a given source location

Install

Dune Dependency

Authors

Maintainers

Sources

pp_loc-v1.0.0.tbz
sha256=ece33db791d5d7fc1e21e77098c766ddb4772984541e3384f68a1e3cf732a015
sha512=32180cfc7bb2664727ad13ef7b0c988d8606ff2f570d9ddf18b46fafd45dcdb5813d7f798e79bf9a3e263c883a8d06bc4aeb7ff95039ff85f5c35f6a144c5bef

Description

Decent error reporting (for example, in a parser, a compiler, ...) typically involves collecting locations, in order to indicate to the user the position of an error in the source file. This library provides support for quoting and highlighting the input fragment that corresponds to a given source location (or set of source locations).

Published: 04 Oct 2021

README

pp_loc

Decent error reporting (for example, in a parser, a compiler, ...) typically involves collecting locations, in order to indicate to the user the position of an error in the source file.

This library provides support to additionally quote and highlight the input fragment the input that corresponds to a location (or a set of locations).

This is the same code as in the OCaml compiler implementation (as of version 4.08), but extracted as a standalone library.

Examples

Single-line errors: the offending line is printed back, and the error location is highlighted using carets.

2 | let x = 1 + 1 +. 2 in ()
            ^^^^^

Multi-line error: the lines that span the location are printed, where the input outside of the error location is replaced by ".".

2 | ......(1 + 1
3 |  * 3)...

Documentation

https://armael.github.io/pp_loc/pp_loc/

Dependencies (2)

  1. dune >= "2.7"
  2. ocaml >= "4.08.0"

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.