diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lab1/tree.mli	Thu Oct 05 08:04:15 2017 +0100
@@ -0,0 +1,38 @@
+(* lab1/tree.mli *)
+(* Copyright (c) 2017 J. M. Spivey *)
+
+type ident = string
+
+(* |name| -- type for applied occurrences, with annotations *)
+type name = 
+  { x_name: ident;              (* Name of the reference *)
+    x_lab: string;              (* Global label *)
+    x_line: int }               (* Line number *)
+
+val make_name : ident -> int -> name
+
+
+(* Abstract syntax *)
+
+type program = Program of stmt
+
+and stmt = 
+    Skip 
+  | Seq of stmt list
+  | Assign of name * expr
+  | Print of expr
+  | Newline
+  | IfStmt of expr * stmt * stmt
+  | WhileStmt of expr * stmt
+
+and expr = 
+    Constant of int 
+  | Variable of name
+  | Monop of Keiko.op * expr 
+  | Binop of Keiko.op * expr * expr
+
+
+(* seq -- neatly join a list of statements into a sequence *)
+val seq : stmt list -> stmt
+
+val print_tree : out_channel -> program -> unit