Suppose I have a function called “dsl_to_ocaml_ast” that can create a valid OCaml Parsetree (ver 4.06.1). I’ve been digging around the OCaml source and can’t find any function that can evaluate/compile a Parsetree. I don’t fully understand the ppx extension interface but is this the only way to take a Parsetree and evaluate/compile it? I’ve played around a bit with “ppx_tools.metaquot” which seems to convince me that I can generate correct Parsetree’s. This tool also doesn’t seem to have an [%eval …] to evaluate the Parsetree’s that it generates. Hope I’m missing something simple.
Evaluation of the AST in compile-time with PPXs is not a very common use case. If you do really need it I suggest looking at how ocamli works, it includes an extension called ppx_eval which might do what you want.
In the future I’ll have to dig deeper into ppx extensions. The biggest problem I’ve had is the examples I’ve been able to find are either too simple or full on extensions so figuring out how to use it fully isn’t so straightforward.