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