annotate lab1/tree.mli @ 1:b5139af1a420 tip basis

Fixed permissions on compile scripts
author Mike Spivey <mike@cs.ox.ac.uk>
date Fri, 13 Oct 2017 17:27:58 +0100
parents bfdcc3820b32
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 (* lab1/tree.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 (* |name| -- type for applied occurrences, with annotations *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 type name =
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 { x_name: ident; (* Name of the reference *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 x_lab: string; (* Global label *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 x_line: int } (* Line number *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 val make_name : ident -> int -> name
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 (* Abstract syntax *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 type program = Program of stmt
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 and stmt =
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 Skip
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 | Seq of stmt list
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 | Assign of name * expr
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 | Print of expr
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 | Newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 | IfStmt of expr * stmt * stmt
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 | WhileStmt of expr * stmt
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 and expr =
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 Constant of int
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 | Variable of name
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 | Monop of Keiko.op * expr
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32 | Binop of Keiko.op * expr * expr
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 (* seq -- neatly join a list of statements into a sequence *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 val seq : stmt list -> stmt
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 val print_tree : out_channel -> program -> unit