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-2.1.0.tbz
sha256=2f736505d431e81a4fe851ad310ff29ec4cd20c8fd37ef050d9e6f1050baa7cb
sha512=7e51eeeb29037d1e1db4ebe4d4d14e40cbb45162970773f35ffe43b6107570ee5d6ec21698791fc8cfd79df5ccfd173fb6b2a8108af7bda976368b13b64ea749

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: 30 May 2022

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 (2)

  1. dolmen_loop >= "0.7"
  2. gospel >= "0.2.0"

Conflicts

None

OCaml

Innovation. Community. Security.