Expand description
Generate ocaml deserialization code for our types.
This binary runs charon on itself and generates the appropriate <type>_of_json
functions for
our types. The generated functions are inserted into ./generate-ml/GAstOfJson.template.ml
to
construct the final GAstOfJson.ml
.
To run it, call cargo run --bin generate-ml
. It is also run by make generate-ml
in the
crate root. Donβt forget to format the output code after regenerating.
StructsΒ§
- Derive
Visitors π - Generate
Code πFor - Replace markers in
template
with auto-generated code. - Generate
Ctx π
EnumsΒ§
- Generation
Kind π - The kind of code generation to perform.
FunctionsΒ§
- build_
branch π - build_
doc_ πcomment - Make a doc comment that contains the given string, indenting it if necessary.
- build_
function π - build_
type π - convert_
vars π - extract_
doc_ πcomments - generate_
ml π - generate_
visitor_ πbases - main π
- make_
ocaml_ πident - repr_
name π Name
is a complex datastructure; to inspect it we serialize it a little bit.- type_
decl_ πto_ json_ deserializer - type_
decl_ πto_ ocaml_ decl - Generate an ocaml type declaration that mirrors
decl
. - type_
name_ πto_ ocaml_ ident - type_
to_ πocaml_ call - Converts a type to the appropriate
*_of_json
call. In case of generics, this combines several functions, e.g.list_of_json bool_of_json
. - type_
to_ πocaml_ name - Converts a type to the appropriate ocaml name. In case of generics, this provides appropriate parameters.