Crate generate_ml

Source
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Β§

DeriveVisitors πŸ”’
GenerateCodeFor πŸ”’
Replace markers in template with auto-generated code.
GenerateCtx πŸ”’

EnumsΒ§

GenerationKind πŸ”’
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.