package nice_parser
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
md5=56355492a47db73a577e2cc692d164ab
sha512=b6aec833d73da71468cad54696f8e1a2be5a6eb77437eca7e533d1f83af426c841f3789d6c71cff79bf5852e94008f6f03bdea1096e10747c00c1e46456a100f
Description
Nice_parser wraps your {menhir, ocamlyacc}-generated parser in a sane interface, eliminating boilerplate code.
Added to opam-repository:
README
For an older version of this repository based on sedlex, refer to the sedlex branch.
Nice_parser 
Writing a parser in OCaml ~requires~ used to require a lot of boilerplate code. Nice_parser changes this:
- The
nice_parserlibrary (API documented here) consolidates boilerplate code that can be shared among all parsers, providing a sane interface (with beautiful error messages) to your {menhir, ocamlyacc}-generated parser. The example folder contains a fully functional parser skeleton based on
Nice_parserand standard tools:
You can get started with your own parser in seconds:
opam install nice_parser # install the nice_parser library
git clone https://github.com/smolkaj/ocaml-parsing.git # clone this repository
cd ocaml-parsing && rm -r src && mv example src # use example as starting point
dune build src/example.a # try to build...
dune exec src/bin/main.exe # ...and run your parser!You should see the following output (the error message relies on OCaml >= 4.08):
Trying to parse "(a b (c d) e)".
-> (List ((Atom a) (Atom b) (List ((Atom c) (Atom d))) (Atom e)))
Trying to parse "(long_atom_with_0123)".
-> (List ((Atom long_atom_with_0123)))
Trying to parse "
( so far so good
but (this is)) illegal (isnt it?)
(* parsing will fail ^^^^^^^ here *)
".
Fatal error: exception Line 3, characters 25-32:
3 | but (this is)) illegal (isnt it?)
^^^^^^^
Error: [parser] unexpected tokenDocumentation
The API is documented here. The example skeleton should be self-explanatory.
How to build
Ideally, use OCaml 4.08 or higher (for beautiful error messages). The project can be built using dune. Consult the dune-project file for the necessary dependencies; all can be installed using opam, OCaml's packet manager.
Suggestions and Improvements
Suggestions and changes are welcome. Please submit pull requests, or open issues.
Dev Dependencies (6)
-
odoc
with-doc -
ppx_expect
with-test & < "v0.13" -
ppx_inline_test
with-test & < "v0.13" -
ppx_jane
with-test & < "v0.13" -
base
with-test & < "v0.13" -
menhir
with-test
Optional Dependencies
None
Used by (1)
Conflicts
None
Build status
Results of building nice_parser with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. 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 |
|---|---|---|---|---|---|
| 1.0.0 (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