]> Joshua Wise's Git repositories - snipe.git/blame_incremental - util/errormsg.sml
Update coloring for Blarg.
[snipe.git] / util / errormsg.sml
... / ...
CommitLineData
1(* L1 Compiler
2 * Error messages
3 * Author: Kaustuv Chaudhuri <kaustuv+@cs.cmu.edu>
4 * Annotations: Alex Vaynberg <alv@andrew.cmu.edu>
5 * Modified: Frank Pfenning <fp@cs.cmu.edu>
6 *)
7
8signature ERRORMSG =
9sig
10 (* clears out all errors from the system *)
11 val reset : unit -> unit
12
13 (* global flag that indicates whether there were errors *)
14 val anyErrors : bool ref
15
16 (* sets the error flag and prints out an error message, does NOT raise ERROR *)
17 val error : Mark.ext option -> string -> unit
18 (* same, but does not increment error count *)
19 val warn : Mark.ext option -> string -> unit
20
21 (* generic code stopping exception *)
22 exception Error
23 exception InternalError of string
24end
25
26structure ErrorMsg :> ERRORMSG =
27struct
28 (* Initial values of compiler state variables *)
29 val anyErrors = ref false
30
31 fun reset() = ( anyErrors := false )
32
33 fun msg str ext note =
34 (anyErrors := true;
35 Option.map (TextIO.print o Mark.show) ext;
36 List.app TextIO.print [":", str, ":", note, "\n"])
37
38 fun error ext note = (anyErrors := true; msg "error" ext note)
39 fun warn ext note = msg "warning" ext note
40
41 (* Print the given error message and then abort compilation *)
42 exception Error
43 exception InternalError of string
44end
This page took 0.025294 seconds and 4 git commands to generate.