annotate ppc/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
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 (* ppc/check.mli *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2 (* Copyright (c) 2017 J. M. Spivey *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 open Tree
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 (*
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 This module is the semantic analysis pass of the compiler. It
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 provides a single function |annotate| that takes a program, checks it
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 for semantic errors, and annotates defining and applied occurrences
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 identifiers with the corresponding definitions. These annotations are
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 used by the code generation pass to generate code for variable
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 references.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 If a semantic error is detected, |annotate| raises the exception
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 |Sem_error|. There is no way of resuming the analysis, and only
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 one error can be detected per run of the compiler.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 (* |annotate| -- check tree for type errors and annotate with definitions *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 val annotate : program -> unit
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 (* |Sem_error| -- semantic error *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 exception Sem_error of string * Print.arg list * int