blob: 9a5ea9ea83a1864bdb8d6aeb62c89c1e2d72db15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
module Message =
struct
type t =
| FileError
| IllegalCharacter
| SyntaxError
| UnboundVariable
| TypeMismatch
| NotInferable
| Bug
let default_severity : t -> Asai.Diagnostic.severity =
function
| FileError -> Error
| IllegalCharacter -> Error
| SyntaxError -> Error
| UnboundVariable -> Error
| TypeMismatch -> Error
| NotInferable -> Error
| Bug -> Bug
let short_code : t -> string =
function
(* operating system errors *)
| FileError -> "E101"
(* parser errors *)
| IllegalCharacter -> "E201"
| SyntaxError -> "E202"
(* elaboration errors *)
| UnboundVariable -> "E301"
| TypeMismatch -> "E302"
| NotInferable -> "E303"
(* misc *)
| Bug -> "E900"
end
include Asai.Reporter.Make(Message)
let file_open_error ~path ~msg = fatalf FileError
"unable to open file '%s': %s" path msg
let illegal_character ~loc char = fatalf ~loc IllegalCharacter
"illegal character '%s'" (Char.escaped char)
let syntax_error ~loc = fatalf ~loc SyntaxError
"syntax error"
let unbound_variable id = fatalf UnboundVariable
"unbound variable '%a'" Ident.pp id
let type_mismatch ?loc fmt_expected expected fmt_found found = fatalf ?loc TypeMismatch
"@[<v>type mismatch:@,expected: @[%a@]@, found: @[%a@]@]"
fmt_expected expected fmt_found found
let not_inferable () = fatalf NotInferable
"cannot infer type"
let bug msg = fatalf Bug msg
|