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