lustrec / src / error.ml @ f9f06e7d
History | View | Annotate | Download (1.77 KB)
1 |
open Format |
---|---|
2 |
|
3 |
type ident = Lustre_types.ident |
4 |
type error_kind = |
5 |
Main_not_found |
6 |
| Main_wrong_kind |
7 |
| No_main_specified |
8 |
| Unbound_symbol of ident |
9 |
| Already_bound_symbol of ident |
10 |
| Unknown_library of ident |
11 |
| Wrong_number of ident |
12 |
| AlgebraicLoop |
13 |
| LoadError of string |
14 |
|
15 |
let return_code kind = |
16 |
match kind with |
17 |
| Main_not_found -> 2 |
18 |
| Main_wrong_kind -> 3 |
19 |
| No_main_specified -> 4 |
20 |
| Unbound_symbol _ -> 5 |
21 |
| Already_bound_symbol _ -> 6 |
22 |
| Unknown_library _ -> 7 |
23 |
| Wrong_number _ -> 8 |
24 |
| AlgebraicLoop -> 9 |
25 |
| LoadError _ -> 10 |
26 |
|
27 |
let pp_error_msg fmt = function |
28 |
| Main_not_found -> |
29 |
fprintf fmt "Could not find the definition of main node %s.@." |
30 |
!Global.main_node |
31 |
| Main_wrong_kind -> |
32 |
fprintf fmt |
33 |
"Node %s does not correspond to a valid main node definition.@." |
34 |
!Global.main_node |
35 |
| No_main_specified -> |
36 |
fprintf fmt "No main node specified (use -node option)@." |
37 |
| Unbound_symbol sym -> |
38 |
fprintf fmt |
39 |
"%s is undefined.@." |
40 |
sym |
41 |
| Already_bound_symbol sym -> |
42 |
fprintf fmt |
43 |
"%s is already defined.@." |
44 |
sym |
45 |
| Unknown_library sym -> |
46 |
fprintf fmt |
47 |
"impossible to load library %s.lusic.@.Please compile the corresponding interface or source file.@." |
48 |
sym |
49 |
| Wrong_number sym -> |
50 |
fprintf fmt |
51 |
"library %s.lusic has a different version number and may crash compiler.@.Please recompile the corresponding interface or source file.@." |
52 |
sym |
53 |
| AlgebraicLoop -> assert false (* should have been handled yet *) |
54 |
| LoadError l -> |
55 |
fprintf fmt |
56 |
"Load error: %s.@." |
57 |
l |
58 |
|
59 |
let pp_warning loc pp_msg = |
60 |
Format.eprintf "%a@.Warning: %t@." |
61 |
Location.pp_loc loc |
62 |
pp_msg |
63 |
|
64 |
let pp_error loc pp_msg = |
65 |
Format.eprintf "@.%a@.Error: @[<v 0>%t@]@." |
66 |
Location.pp_loc loc |
67 |
pp_msg |
68 |
|
69 |
|