annotate lab2/dict.mli @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 (* lab2/dict.mli *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2 (* Copyright (c) 2017 J. M. Spivey *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 type ident = string
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 type ptype =
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 Integer
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 | Boolean
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 | Array of int * ptype
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 | Void
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 (* |def| -- definitions in environment *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 type def =
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 { d_tag: ident; (* Name *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 d_type: ptype; (* Type *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 d_lab: string } (* Global label *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 type environment
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 (* |define| -- add a definition, raise Exit if already declared *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 val define : def -> environment -> environment
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 (* |lookup| -- search an environment or raise Not_found *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 val lookup : ident -> environment -> def
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 (* |init_env| -- initial empty environment *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 val init_env : environment