Create an OCaml backend for Mlang
Mlang currently only has a Python backend. The next backend that we would want to add is an OCaml backend, as we would want to perform fuzzing on the code generated from Mlang : https://caml.inria.fr/pub/docs/manual-ocaml/afl-fuzz.html.
The OCaml backend should follow a structure similar to the Python backend in src/mlang/backend_compilers/bir_to_python.ml
, and use a type like this one for the values of the generated program:
type m_value =
| Undefined
| Float of float
Also, the generated OCaml should include preprocessor directives that link back to the original M and M++ source files for better error reporting during the fuzzing. This can be done using the following syntax:
(* file foo.ml *)
let bar = assert false in
# 5 "foo_1.ml"
let baz = assert false in
# 85 "foo_2.ml
let fizz = assert false in
In this example, the assert false
will point to:
-
bar
-> line 2 offoo.ml
-
baz
-> line 5 offoo_1.ml
-
fizz
-> line 85 offoo_2.ml
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information