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

doc/README.html

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).