package pacomb
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=73091a8efb6d166a5efc674343a67ff5da2d84bc61233547edf77b70e73971d6
md5=64369d06ca0eae64cf14f0e030103347
doc/README.html
PaComb: an efficient parsing library for OCaml
PaComb implements a representation of grammars with semantic actions (values returned as a result of parsing). Parsing is performed by compiling grammars defined with the Grammar
module (or indirectly though a PPX extension) to the combinators of the Combinator
module. The library offers scanner less parsing, but the Lex
module provide a notion of terminals and blanks that give a simple way to write grammars in two phases, as usual.
The main advantage of PaComb and similar solutions, contrary to ocamlyacc, is that grammars (compiled or not) are first class values. This allows using the full power of OCaml for manipulating grammars. For example, this is very useful when working with syntax extension mechanisms.
Importantly, the performances of PaComb are very good: it is only two to five times slower than grammars generated by ocamlyacc, which is a compiler.
Defining languages using the Grammar
module directly is cumbersome. For that reason, PaComb provides a BNF-like PPX syntax extension (enabled using the -ppx pacombPpx
compilation flag). An example with arithmetic expressions is