Representing ranges of lexing positions from parsed files
  • OCaml 92.6%
  • Shell 3.8%
  • Dune 2.8%
  • Makefile 0.8%
Find a file
2026-09-08 12:00:48 +02:00
.github Upgrade CI 2026-09-08 12:00:48 +02:00
.vscode Update spell config 2024-11-04 10:55:40 +01:00
src Apply fmt changes 2026-03-24 09:10:03 +01:00
test Add dunolint workflow 2025-12-16 00:18:25 +01:00
.gitattributes Attempt to fix offset tests divergence in Windows CI 2026-01-09 13:39:09 +01:00
.gitignore Lint 2025-11-07 18:18:10 +01:00
.headache.config Add headache config 2025-09-12 11:01:29 +02:00
.ocamlformat Upgrade ocamlformat to 0.29.0 2026-03-24 09:10:03 +01:00
CHANGES.md Prepare release 2026-01-25 15:14:24 +01:00
CODE_OF_CONDUCT.md Adopt OCaml Code of Conduct 2024-11-10 18:00:21 +01:00
CODEOWNERS Initiate code owners file for GH 2026-02-01 08:06:07 +01:00
COPYING.HEADER Add headache config 2025-09-12 11:01:29 +02:00
dune init 2023-11-12 21:06:50 +01:00
dune-project Upgrade ocamlformat to 0.29.0 2026-03-24 09:10:03 +01:00
dune-workspace.4.14 Upgrade OCaml to latest available versions 2026-09-08 10:03:55 +02:00
dune-workspace.5.2 Upgrade CIs 2026-04-12 14:12:53 +02:00
dune-workspace.5.3 Upgrade CIs 2026-04-12 14:12:53 +02:00
dune-workspace.5.4 Upgrade CIs 2026-04-12 14:12:53 +02:00
dune-workspace.5.5 Upgrade OCaml to latest available versions 2026-09-08 10:03:55 +02:00
dunolint Add dunolint workflow 2025-12-16 00:18:25 +01:00
headache.sh Remove left-over unused var (shellcheck) 2026-03-17 11:49:20 +01:00
LICENSE License year 2025-09-12 11:01:08 +02:00
loc-dev.opam Upgrade ocamlformat to 0.29.0 2026-03-24 09:10:03 +01:00
loc-tests.opam Revert dune version constraint 2025-12-20 22:42:30 +01:00
loc-tests.opam.template Add opam template file and configure more fields 2024-12-02 13:22:29 +01:00
loc.opam Add transitive dyn dependency explicitly 2025-11-07 17:31:16 +01:00
loc.opam.template Add opam template file and configure more fields 2024-12-02 13:22:29 +01:00
Makefile Prepare release 2024-09-03 13:29:17 +02:00
README.md Merge branch internal changes into main 2024-09-26 12:22:02 +02:00

loc

CI Status Coverage Status

Loc is an OCaml library to manipulate code locations, which are ranges of lexing positions from a parsed file.

It is inspired by dune's Loc.t, and uses it under the hood. The type equality with Stdune.Loc.t is currently not exposed and Stdune not mentioned in the interface of Loc, with the aim of keeping the signature of Loc stable across potential internal changes in Stdune.

Code Documentation

The code documentation of the latest release is built with odoc and published to GitHub pages here.

Motivation

Attaching locations to nodes manipulated by programs can be useful for applications such as compilers, interpreters, linters, refactor tools, etc.

Here are 3 kinds of examples using the Loc library:

  1. Attach locations to the nodes of an AST. See bopkit.
  2. Apply surgical patches to a file. See file-rewriter.
  3. Emit located messages to the console. See cmdlang's Err module.

See also

Similar libraries or modules: