comparison lab3/tree.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/tree.mli *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 open Dict
5
6 (* |name| -- type for applied occurrences with annotations *)
7 type name =
8 { x_name: ident; (* Name of the reference *)
9 x_line: int; (* Line number *)
10 mutable x_def: def option} (* Definition in scope *)
11
12 type expr =
13 Constant of int
14 | Variable of name
15 | Monop of Keiko.op * expr
16 | Binop of Keiko.op * expr * expr
17 | Call of name * expr list
18
19 type stmt =
20 Skip
21 | Seq of stmt list
22 | Assign of name * expr
23 | Return of expr
24 | IfStmt of expr * stmt * stmt
25 | WhileStmt of expr * stmt
26 | Print of expr
27 | Newline
28
29 type block = Block of ident list * proc list * stmt
30
31 and proc = Proc of name * ident list * block
32
33 type program = Program of block
34
35
36 (* seq -- neatly join a list of statements into a sequence *)
37 val seq : stmt list -> stmt
38
39 val makeName : ident -> int -> name
40
41 (* |get_def| -- rerieve definition from name *)
42 val get_def : name -> def
43
44 (* |print_tree| -- pretty-print a tree *)
45 val print_tree : out_channel -> program -> unit