Pretty-printing for error source locations
  • OCaml 95.3%
  • Dune 3.2%
  • Makefile 1.5%
Find a file
2022-06-01 14:15:57 +02:00
.github/workflows also run CI on PRs 2022-06-01 14:08:08 +02:00
lib fix some trailing whitespaces 2022-06-01 14:10:09 +02:00
tests fix some trailing whitespaces 2022-06-01 14:10:09 +02:00
.gitignore initial code dump 2019-08-04 17:59:56 +02:00
CHANGES update CHANGES 2022-05-30 11:07:59 +02:00
dune-project fix some trailing whitespaces 2022-06-01 14:10:09 +02:00
LICENSE chore: add LICENSE & CHANGES files 2021-09-29 13:51:04 +02:00
Makefile add basic test 2022-04-20 10:34:57 -04:00
pp_loc.opam pp_loc.opam: update version 2022-05-30 19:06:59 +02:00
README.md Add link to the documentation 2019-08-05 12:39:31 +02:00

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/