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.0.0.tbz
sha256=1bb7e9717a8b88f48b2fc8c8cb72d43a124a41e76619a1c3e1f7c7aa1d7580a4
sha512=e7830948cb7dd4becb0b94c3a13f7d134d4c817b64a1cac980b40c0efd369e15ec4cd3b2ba63476b844330ec52d6f37a385346e6bb3ad125591f2405ed7a7a60

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: 28 Apr 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 (1)

  1. dolmen_loop >= "0.7"

Conflicts

None

OCaml

Innovation. Community. Security.