diff lab3/dict.mli @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lab3/dict.mli	Thu Oct 05 08:04:15 2017 +0100
@@ -0,0 +1,35 @@
+(* lab3/dict.mli *)
+(* Copyright (c) 2017 J. M. Spivey *)
+
+type ident = string
+
+type codelab = int
+
+val label : unit -> codelab
+
+(* |def| -- definitions in environment *)
+type def = 
+  { d_tag : ident;              (* Name *)
+    d_kind : def_kind;          (* Definition *)
+    d_level : int;              (* Nesting level *)
+    d_lab : string;             (* Label if global *)
+    d_off : int }               (* Offset if local *)
+
+and def_kind =
+    VarDef                      (* Variable *)
+  | ProcDef of int              (* Procedure (nparams) *)
+
+type environment
+
+(* |define| -- add a definition, raise Exit if already declared *)
+val define : def -> environment -> environment
+
+(* |lookup| -- search an environment or raise Not_found *)
+val lookup : ident -> environment -> def
+
+(* |new_block| -- add new block to top of environment *)
+val new_block : environment -> environment
+
+(* |empty| -- initial empty environment *)
+val empty : environment
+