diff lab2/check.mli @ 0:bfdcc3820b32

author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lab2/check.mli	Thu Oct 05 08:04:15 2017 +0100
@@ -0,0 +1,23 @@
+(* lab2/check.mli *)
+(* Copyright (c) 2017 J. M. Spivey *)
+This module is the semantic analysis pass of the compiler.  It
+provides a single function |annotate| that takes a program, checks it
+for semantic errors, and annotates each applied occurrence of an
+identifier with the corresponding definition.  These annotations are
+used by the code generation pass to generate code for variable
+If a semantic error is detected, |annotate| raises the exception
+|Semantic_error|.  Its arguments are a line number and a format and
+argument list that can be passed to printf to print the message.
+Because there is no way of resuming the analysis, only one error can
+be detected per run of the compiler.
+(* |annotate| -- check tree for type errors and annotate with definitions *)
+val annotate : Tree.program -> unit
+(* |Semantic_error| -- exception raised if error detected *)
+exception Semantic_error of string * Print.arg list * int