Using ppx for code generation

My experience with generating OCaml bindings from the vulkan specification file is that manipulating OCaml AST with the help of ppx_metaquot scales better beyond a certain size. Depending on your aims, it may not be necessary to use the ppx API proper: the ppx API would be useful to insert generated content inside preexisting OCaml source file; but generating standalone OCaml source files can be done directly using the compiler-libs library and printing the generated AST with Pprintast.

2 Likes