module Compiler_util2:sig
..end
Support code for writing a simple compiler.
typeid =
string
val pp_id : Format.formatter -> id -> Ppx_deriving_runtime.unit
val show_id : id -> Ppx_deriving_runtime.string
type
op2 =
| |
LT |
| |
GT |
| |
Eq |
| |
Add |
| |
Sub |
| |
Mul |
| |
Div |
| |
Mod |
val pp_op2 : Format.formatter -> op2 -> Ppx_deriving_runtime.unit
val show_op2 : op2 -> Ppx_deriving_runtime.string
type
const =
| |
Int of |
| |
Bool of |
val pp_const : Format.formatter -> const -> Ppx_deriving_runtime.unit
val show_const : const -> Ppx_deriving_runtime.string
type
exp =
| |
Id of |
| |
Const of |
| |
Op2 of |
| |
If of |
| |
Let of |
| |
Fun of |
| |
App of |
| |
MkArray of |
| |
GetArray of |
| |
SetArray of |
| |
Seq of |
| |
Abort |
val pp_exp : Format.formatter -> exp -> Ppx_deriving_runtime.unit
val show_exp : exp -> Ppx_deriving_runtime.string
type
value =
| |
Int of |
| |
Bool of |
| |
Array of |
| |
Closure of |
module IdSet:Set.S
with type elt = id
val from_string : string -> exp
val from_file : string -> exp
val show_value : value -> id
val eval : exp -> value
eval e
evaluates e
with an interpreter. The interpreter throws
exceptions if e
has type errors, free variables, etc.
val free_vars : exp -> IdSet.t
free_vars e
produces the free variables of e
.
val subst : id ->
exp -> exp -> exp
subst x u e
substitutes all occurrences of x
with u
in []e. The
* function assumes that u
has no free variables.