comparison lab2/check.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 (* lab2/check.mli *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 (*
5 This module is the semantic analysis pass of the compiler. It
6 provides a single function |annotate| that takes a program, checks it
7 for semantic errors, and annotates each applied occurrence of an
8 identifier with the corresponding definition. These annotations are
9 used by the code generation pass to generate code for variable
10 references.
11
12 If a semantic error is detected, |annotate| raises the exception
13 |Semantic_error|. Its arguments are a line number and a format and
14 argument list that can be passed to printf to print the message.
15 Because there is no way of resuming the analysis, only one error can
16 be detected per run of the compiler.
17 *)
18
19 (* |annotate| -- check tree for type errors and annotate with definitions *)
20 val annotate : Tree.program -> unit
21
22 (* |Semantic_error| -- exception raised if error detected *)
23 exception Semantic_error of string * Print.arg list * int