Dear camlers, I am pleased to announce the release of pacomb 1.4.
Pacomb is a library + ppx to write grammars. It support: self extensible grammars, ambiguous grammars (with merge), late rejection of rule via raising exception from action code, priority and others. Is it relatively fast because it is compiled to efficient combinators. More details are available in the git page and the documentation.
As teaser, the usual calculator example:
(* The three levels of priorities *)
type p = Atom | Prod | Sum
let%parser rec
(* This includes each priority level in the next one *)
expr p = Atom < Prod < Sum
(* all other rules are selected by their priority level *)
; (p=Atom) (x::FLOAT) => x
; (p=Atom) '(' (e::expr Sum) ')' => e
; (p=Prod) (x::expr Prod) '*' (y::expr Atom) => x*.y
; (p=Prod) (x::expr Prod) '/' (y::expr Atom) => x/.y
; (p=Sum ) (x::expr Sum ) '+' (y::expr Prod) => x+.y
; (p=Sum ) (x::expr Sum ) '-' (y::expr Prod) => x-.y
Here is a list of the main changes from 1.3:
-
Add a “not charset combinator” for regexp [!..], it is distinct from [^…] as it parses nothing.
-
File was not closed by Grammar.parse_file in case of parse error
-
New Grammar.set_debug_merge to allow debugging ambiguous grammars (report by Matthieu Lemerre)
-
Compatibility with latest ocaml and ppxlib
-
Travis action to check compilation
-
Various documentation fix
Possible roadmap for future version:
- 1.5 : integrate a lexical entry for ocaml code with call back for specific {xxx| … |xxx}. This is code existing in simple_httpd’s chaml parser (equivalent to php but in cocaml), that I wish to integrate in pacomb.
- 2.0 : rewrite the combinators with algebraic effects. The semantics will be much better than the current implementation using references.
Cheers,
Christophe