what is the state-of-the-art way to generate (programmatically) and
pretty-print a valid OCaml AST? Should I use camlp4 or is there a
standalone-library?
Camlp4 is being deprecated and will be distributed as a separate
package starting with OCaml 4.02. You should now use the compiler
libraries which export the same AST used by the compiler [1] as well
as pretty-printers [2]. These are available through the findlib package
compiler-libs.common. To help produce the AST you can use ppx_tools [3].