package minicaml

  1. Overview
  2. Docs
type ide = string

A value identifier

val equal_ide : ide -> ide -> Ppx_deriving_runtime.bool
val compare_ide : ide -> ide -> Ppx_deriving_runtime.int
type complext = Complex.t

A type wrapper for complex numbers where equality, ordering and showing are defined

val show_complext : complext -> Ppx_deriving_runtime.string
val equal_complext : complext -> complext -> Ppx_deriving_runtime.bool
val compare_complext : complext -> complext -> Ppx_deriving_runtime.int
type puret =
  1. | Uncertain
  2. | Pure
  3. | Impure

A type representing if a computation is pure or not

val equal_puret : puret -> puret -> Ppx_deriving_runtime.bool
val compare_puret : puret -> puret -> Ppx_deriving_runtime.int
type expr =
  1. | Unit
  2. | Purity of puret * expr
  3. | NumInt of int
  4. | NumFloat of float
  5. | NumComplex of complext
  6. | Boolean of bool
  7. | String of string
  8. | Symbol of ide
  9. | List of expr list
  10. | Cons of expr * expr
  11. | ConcatLists of expr * expr
  12. | ConcatStrings of expr * expr
  13. | Dict of (expr * expr) list
  14. | Plus of expr * expr
  15. | Sub of expr * expr
  16. | Div of expr * expr
  17. | Mult of expr * expr
  18. | Eq of expr * expr
  19. | Gt of expr * expr
  20. | Lt of expr * expr
  21. | Ge of expr * expr
  22. | Le of expr * expr
  23. | And of expr * expr
  24. | Or of expr * expr
  25. | Not of expr
  26. | IfThenElse of expr * expr * expr
  27. | Let of (ide * expr) list * expr
  28. | Letlazy of (ide * expr) list * expr
  29. | Letrec of ide * expr * expr
  30. | Letreclazy of ide * expr * expr
  31. | Lambda of ide list * expr
  32. | Apply of expr * expr list
  33. | Sequence of expr list
  34. | Pipe of expr * expr

The type representing Abstract Syntax Tree expressions

val equal_expr : expr -> expr -> Ppx_deriving_runtime.bool
val compare_expr : expr -> expr -> Ppx_deriving_runtime.int
type command =
  1. | Expr of expr
  2. | Def of (ide * expr) list
  3. | Defrec of (ide * expr) list

A type useful for evaluating files, stating if a command is an expression or simply a "global" declaration (appended to environment)

val show_command : command -> Ppx_deriving_runtime.string
val equal_command : command -> command -> Ppx_deriving_runtime.bool
val compare_command : command -> command -> Ppx_deriving_runtime.int
type 'a env_t = (string * 'a) list

A purely functional environment type, parametrized

val equal_env_t : 'a. ('a -> 'a -> Ppx_deriving_runtime.bool) -> 'a env_t -> 'a env_t -> Ppx_deriving_runtime.bool
val compare_env_t : 'a. ('a -> 'a -> Ppx_deriving_runtime.int) -> 'a env_t -> 'a env_t -> Ppx_deriving_runtime.int
type evt =
  1. | EvtUnit
  2. | EvtInt of int
  3. | EvtFloat of float
  4. | EvtComplex of complext
  5. | EvtBool of bool
  6. | EvtString of string
  7. | EvtList of evt list
  8. | EvtDict of (evt * evt) list
  9. | Closure of ide list * expr * type_wrapper env_t
    (*

    RecClosure keeps the function name in the constructor for recursion

    *)
  10. | RecClosure of ide * ide list * expr * type_wrapper env_t
    (*

    Abstraction that permits treating primitives as closures

    *)
  11. | PrimitiveAbstraction of primitivet

A type that represents an evaluated (reduced) value

and type_wrapper =
  1. | LazyExpression of expr
  2. | AlreadyEvaluated of evt
and primitivet = ide * int * type_wrapper env_t * puret
val show_type_wrapper : type_wrapper -> Ppx_deriving_runtime.string
val show_primitivet : primitivet -> Ppx_deriving_runtime.string
val equal_evt : evt -> evt -> Ppx_deriving_runtime.bool
val equal_type_wrapper : type_wrapper -> type_wrapper -> Ppx_deriving_runtime.bool
val equal_primitivet : primitivet -> primitivet -> Ppx_deriving_runtime.bool
val compare_evt : evt -> evt -> Ppx_deriving_runtime.int
val compare_type_wrapper : type_wrapper -> type_wrapper -> Ppx_deriving_runtime.int
val compare_primitivet : primitivet -> primitivet -> Ppx_deriving_runtime.int
val generate_prim_params : int -> string list
val show_unpacked_evt : evt -> Ppx_deriving_runtime.string
type env_type = type_wrapper env_t

An environment of already evaluated values

type stackframe =
  1. | StackValue of int * expr * stackframe
  2. | EmptyStack

A recursive type representing a stacktrace frame

val show_stackframe : stackframe -> Ppx_deriving_runtime.string
val push_stack : stackframe -> expr -> stackframe

Push an AST expression into a stack

  • parameter s

    The stack where to push the expression

  • parameter e

    The expression to push

val pop_stack : stackframe -> stackframe

Pop an AST expression from a stack

val depth_of_stack : stackframe -> int
type evalstate = {
  1. env : env_type;
  2. verbosity : int;
  3. stack : stackframe;
  4. printresult : bool;
  5. purity : puret;
}

Options for the eval function, includes

exception UnboundVariable of string

Exceptions

exception WrongPrimitiveArgs
exception TypeError of string
exception ListError of string
exception DictError of string
exception SyntaxError of string
exception FileNotFoundError of string
exception PurityError of string
OCaml

Innovation. Community. Security.