Camlp4

Camlp4 stands for Caml Preprocessor and Pretty-Printer and one of its most important applications was the definition of domain-specific extensions of the syntax of OCaml.

It can be output in a binary form, e.g. it can be passed directly to one of the OCaml compilers, or it can be converted back into a clear text program.

They would all converge to an abstract syntax tree in a unique format that a compiler can handle.

Several libraries are provided which facilitate the specific manipulation of OCaml syntax trees.

The only thing that the developer has to do is write a Camlp4 grammar which converts the domain-specific language in question into a regular OCaml program.

A syntax extension is defined by a compiled OCaml module, which is passed to the camlp4o executable along with the program to process.