package pratter
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=f690a04270747947277e06116a13a5b163413439d72c1a902a2bff9abe548ad6
sha512=03a06fe36bad084f9f3730526d0cdf9a410d137256329455df6a4c97421ab0a30b859140f54e72e6e26d86c455a257ff391de007680b8c7bcec013cbd307ad19
Description
Pratter is a top-down operator precedence parser that allows to parse expressions with infix, prefix and postfix operators.
Added to opam-repository:
README
Pratter
Copyright Deducteam
Pratter is a library that allows to parse expressions with infix, postfix or prefix operators.
Pratter is a top-down operator precedence parser that implements the Pratt parsing algorithm. In contrast with Menhir or ocamlyacc, Pratter is a parser, not a parser generator: no code is produced during compilation. In consequence, parsing rules can be modified dynamically. On the other hand, Pratter parses a much more restricted class of grammars called operator grammars while Menhir and ocamlyacc parse LR(1) and LALR(1) grammars respectively.
You are free to copy, modify and distribute Pratter with attribution under the terms of the BSD 3 Clause license. See the license for more details.
Getting started
To compile and use pratter, you need
- ocaml >= 4.10
- dune >= 2.7
Then, at the root of the source tree,
$ make installTo ensure it's working write the following code in some file plus.ml to parse the language defined by the grammar T ::= T + T | id where id denotes identifiers
type t = A of t * t | S of string
let appl t u = A (t, u)
let token = Fun.id
let ops = function
| S "+" as s -> Pratter.[ Infix Left, 0.3, s ]
| _ -> []
let parse = Pratter.expression ~token ~appl ~ops
let () =
let input = List.to_seq [ S "x"; S "+"; S "y"] in
assert (Result.is_ok @@ Pratter.run parse input)then execute the following lines which should return 0
$ echo "module Pratter = struct $(cat pratter.ml) end $(cat plus.ml)" > plus_.ml
$ ocamlc plus_.ml
$ ./a.outWhat next?
- There's a change log.
- There's a license.
- This file is another use case example that is slightly more involved than the one in this readme.
You can report issues, ask questions or start discussions using the issue tracker.
Dev Dependencies (4)
-
odoc
with-doc -
qcheck-alcotest
with-test & >= "0.12" -
qcheck
with-test & >= "0.12" -
alcotest
with-test & >= "1.5.0" & < "2"
Optional Dependencies
None
Used by (1)
-
lambdapi
>= "3.0.0"
Conflicts
None
Build status
Results of building pratter with each compiler on check.ci.ocaml.org, run of against opam-repository 78c202b. 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 |
|---|---|---|---|---|---|
| 5.0.2 (this version) | good | 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