package minicaml

  1. Overview
  2. Docs
type ide = string

A value identifier

val pp_ide : Ppx_deriving_runtime.Format.formatter -> ide -> Ppx_deriving_runtime.unit
val equal_ide : ide -> ide -> Ppx_deriving_runtime.bool
val compare_ide : ide -> ide -> Ppx_deriving_runtime.int
type expr =
  1. | Unit
  2. | Integer of int
  3. | Boolean of bool
  4. | String of string
  5. | Symbol of ide
  6. | List of expr list
  7. | Cons of expr * expr
  8. | Dict of (expr * expr) list
  9. | Plus of expr * expr
  10. | Sub of expr * expr
  11. | Mult of expr * expr
  12. | Eq of expr * expr
  13. | Gt of expr * expr
  14. | Lt of expr * expr
  15. | Ge of expr * expr
  16. | Le of expr * expr
  17. | And of expr * expr
  18. | Or of expr * expr
  19. | Not of expr
  20. | IfThenElse of expr * expr * expr
  21. | Let of (ide * expr) list * expr
  22. | Letlazy of (ide * expr) list * expr
  23. | Letrec of ide * expr * expr
  24. | Letreclazy of ide * expr * expr
  25. | Lambda of ide list * expr
  26. | Apply of expr * expr list
  27. | Sequence of expr list
  28. | Pipe of expr * expr

The type representing Abstract Syntax Tree expressions

val pp_expr : Ppx_deriving_runtime.Format.formatter -> expr -> Ppx_deriving_runtime.unit
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 pp_command : Ppx_deriving_runtime.Format.formatter -> command -> Ppx_deriving_runtime.unit
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 pp_env_t : 'a. (Ppx_deriving_runtime.Format.formatter -> 'a -> Ppx_deriving_runtime.unit) -> Ppx_deriving_runtime.Format.formatter -> 'a env_t -> Ppx_deriving_runtime.unit
val show_env_t : 'a. (Ppx_deriving_runtime.Format.formatter -> 'a -> Ppx_deriving_runtime.unit) -> 'a env_t -> Ppx_deriving_runtime.string
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. | EvtBool of bool
  4. | EvtString of string
  5. | EvtList of evt list
  6. | EvtDict of (evt * evt) list
  7. | Closure of ide list * expr * type_wrapper env_t
    (*

    RecClosure keeps the function name in the constructor for recursion

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

    Abstraction that permits treating primitives as closures

    *)
  9. | PrimitiveAbstraction of ide * int * type_wrapper env_t

A type that represents an evaluated (reduced) value

and type_wrapper =
  1. | LazyExpression of expr
  2. | AlreadyEvaluated of evt
val pp_evt : Ppx_deriving_runtime.Format.formatter -> evt -> Ppx_deriving_runtime.unit
val pp_type_wrapper : Ppx_deriving_runtime.Format.formatter -> type_wrapper -> Ppx_deriving_runtime.unit
val show_type_wrapper : type_wrapper -> 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 compare_evt : evt -> evt -> Ppx_deriving_runtime.int
val compare_type_wrapper : type_wrapper -> type_wrapper -> 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 pp_stackframe : Ppx_deriving_runtime.Format.formatter -> stackframe -> Ppx_deriving_runtime.unit
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

exception UnboundVariable of string
exception TooManyArgs of string
exception WrongBindList
exception WrongPrimitiveArgs
exception TypeError of string
exception ListError of string
exception DictError of string
exception SyntaxError of string