package parkour

All checked builds pass
  1. Overview
  2. Docs
Parser combinators with excellent error messages and error recovery

Install

dune-project
 Dependency

Authors

Maintainers

Sources

parkour-0.1.1.tar.gz
sha256=c4a3f934273430011f6c4862c035395268c47b2cdaba52c199f97cf0404dfba9
sha512=45194b2c7d5f8bcc9d2cb92d640b9dff17b2a3d4ad7319c006daf523923d8c69cdaf53e11d25ba01d5a470b027e4fa1788a69669d11481db20773cef6cc6fa49

Description

Parkour is a parser-combinator library for human-authored text such as configuration files, DSLs and small languages. It reports precise, well-rendered syntax errors with structured diagnostics, offers opt-in error recovery that reports many problems in one run, works on strings or token streams, and is stack-safe on long and deeply nested input (nesting depth is limited). It has no runtime dependencies beyond the OCaml standard library.

Tags

parser parser combinators error recovery dsl

Added to opam-repository:

README

Parkour

A parser-combinator library for OCaml, for human-authored text (config files, DSLs, small languages). It aims for precise syntax errors, a pleasant API, opt-in error recovery and stack safety on long and deeply nested input. No runtime dependencies beyond the OCaml standard library.

open Parkour

let point =
  let+ x = integer <* char ',' and+ y = integer in
  (x, y)

let () =
  match parse point "3,x" with
  | Ok (x, y) -> Printf.printf "%d %d\n" x y
  | Error ds ->
      let source = Source.make ~name:"point" "3,x" in
      List.iter (fun d -> print_string (Diagnostic.render source d)) ds

prints

error: expected integer, found 'x'
 --> point:1:3
  |
1 | 3,x
  |   ^ expected integer

Documentation

A tutorial and the API reference, built with

dune build @doc

(open _build/default/_doc/_html/index.html). The examples/ directory has complete parsers (JSON, CSV, typed values, a calculator, a configuration format with error recovery, a small C-like language), each with a gallery of broken inputs and the errors they produce.

Development

Command

dune build

build the library

dune test

fast test tier

dune build @test-long

extensive test tier (QCheck --long)

dune fmt

format the sources

bench/fetch.sh && dune exec --profile bench bench/main.exe

benchmarks (unpackaged; fetch.sh downloads the inputs)

See CHANGES for the release notes. License: MIT (see LICENSE).

Dependencies (2)

  1. ocaml >= "4.14"
  2. dune >= "3.5"

Dev Dependencies (2)

  1. odoc with-doc
  2. qcheck-core with-test & >= "0.90"

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

Results of building parkour with each compiler on check.ci.ocaml.org, run of against opam-repository 8d8d144. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.1.1 (this version) n/a good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure