package mazeppa

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Checked_oint = Checked_oint
module Symbol : sig ... end
module Const : sig ... end
module Raw_term : sig ... end
module Raw_program : sig ... end
module Gensym : sig ... end
exception Panic of string

Something went wrong...

val supercompile : Raw_program.t -> Raw_program.t

Supercompiles an input program to an equivalent output program. May raise Panic during the process.

You can call this function as many times as you want, including in parallel.

val check : Raw_program.t -> unit

Raises Panic if a given program is not well-formed. To be used as a sanity check before supercompile and eval.

Evaluates a given program to a value, as defined by the language semantics. May raise Panic during the process.

The input program must be well-formed as per the language definition. The main function must be defined with zero parameters. If any of these conditions is violated, the result is either Panic or an incorrect value.

Just as supercompile, this function can be called in parallel.

val translate_to_c : oc:Stdlib.out_channel -> entry:Symbol.t -> Raw_program.t -> unit

Translates a given Mazeppa program to C11 (with GNU extensions).

oc is the output channel to which the resulting C code will be written. The input program must have the main function defined (otherwise, Panic will be raised); entry will be the name of an extern C function that will correspond to your original main. If there is a scoping violation (such as referencing an undefined variable), Panic will be raised.

entry will be the only generated function with external linkage. For example, if your main function looks like this:

main(xs, ys, zs) := append(append(xs, ys), zs);

then the corresponding C function will have the following prototype:

extern mz_Value entry(mz_Value, mz_Value, mz_Value);

where mz_Value refers to the type definition from mazeppa.h.

val mazeppa_h : Stdlib.out_channel -> unit

Writes the contents of mazeppa.h to oc.

This header is required to compile any source file generated by translate_to_c.

OCaml

Innovation. Community. Security.