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