Explanation of the syntax switching between Reason and OCaml


#1

Hey,

So I was wondering if anyone had any resources that explain how the process of using Reason syntax with OCaml’s AST actually work.

Resources focused on Reason and OCaml specifically would be great but if anyone knows of other projects where something similar is done, I’d love to hear about that too!

Thanks,
Richey


#2

OCaml compilers (including ocamlc & bucklescript) will accept source files either in .ml syntax, or as a binary representation of the already-parsed AST.
When your build tool sees a .re file, it passes the contents to refmt, which parses the reason syntax and outputs the binary representation of the AST, which ocamlc can then run with.