comparison lab1/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 (* lab1/tree.mli *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 type ident = string
5
6 (* |name| -- type for applied occurrences, with annotations *)
7 type name =
8 { x_name: ident; (* Name of the reference *)
9 x_lab: string; (* Global label *)
10 x_line: int } (* Line number *)
11
12 val make_name : ident -> int -> name
13
14
15 (* Abstract syntax *)
16
17 type program = Program of stmt
18
19 and stmt =
20 Skip
21 | Seq of stmt list
22 | Assign of name * expr
23 | Print of expr
24 | Newline
25 | IfStmt of expr * stmt * stmt
26 | WhileStmt of expr * stmt
27
28 and expr =
29 Constant of int
30 | Variable of name
31 | Monop of Keiko.op * expr
32 | Binop of Keiko.op * expr * expr
33
34
35 (* seq -- neatly join a list of statements into a sequence *)
36 val seq : stmt list -> stmt
37
38 val print_tree : out_channel -> program -> unit