comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 (* lab3/dict.mli *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 type ident = string
5
6 type codelab = int
7
8 val label : unit -> codelab
9
10 (* |def| -- definitions in environment *)
11 type def =
12 { d_tag : ident; (* Name *)
13 d_kind : def_kind; (* Definition *)
14 d_level : int; (* Nesting level *)
15 d_lab : string; (* Label if global *)
16 d_off : int } (* Offset if local *)
17
18 and def_kind =
19 VarDef (* Variable *)
20 | ProcDef of int (* Procedure (nparams) *)
21
22 type environment
23
24 (* |define| -- add a definition, raise Exit if already declared *)
25 val define : def -> environment -> environment
26
27 (* |lookup| -- search an environment or raise Not_found *)
28 val lookup : ident -> environment -> def
29
30 (* |new_block| -- add new block to top of environment *)
31 val new_block : environment -> environment
32
33 (* |empty| -- initial empty environment *)
34 val empty : environment
35