Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / error.ml @ d75eb6f1

History | View | Annotate | Download (1.77 KB)

1 9094307a ploc
open Format
2
3 8446bf03 ploc
type ident = Lustre_types.ident
4 9094307a ploc
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 f9f06e7d ploc
  | LoadError of string
14 9094307a ploc
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 f9f06e7d ploc
  | LoadError _ -> 10
26 9094307a ploc
27 f4cba4b8 ploc
28 9094307a ploc
  let pp_error_msg fmt = function
29
  | Main_not_found ->
30
      fprintf fmt "Could not find the definition of main node %s.@."
31
	!Global.main_node
32
  | Main_wrong_kind ->
33
    fprintf fmt
34
      "Node %s does not correspond to a valid main node definition.@." 
35
      !Global.main_node 
36
  | No_main_specified ->
37
    fprintf fmt "No main node specified (use -node option)@."
38
  | Unbound_symbol sym ->
39
    fprintf fmt
40
      "%s is undefined.@."
41
      sym
42
  | Already_bound_symbol sym -> 
43
    fprintf fmt
44
      "%s is already defined.@."
45
      sym
46
  | Unknown_library sym ->
47
    fprintf fmt
48
      "impossible to load library %s.lusic.@.Please compile the corresponding interface or source file.@."
49
      sym
50
  | Wrong_number sym ->
51
    fprintf fmt
52
      "library %s.lusic has a different version number and may crash compiler.@.Please recompile the corresponding interface or source file.@."
53
      sym
54 38ae7765 ploc
  | AlgebraicLoop  -> assert false (* should have been handled yet *)
55 f9f06e7d ploc
  | LoadError l -> 
56
    fprintf fmt
57
      "Load error: %s.@."
58
      l
59 74ca6b61 ploc
     
60 264a4844 ploc
let pp_warning loc pp_msg =
61
  Format.eprintf "%a@.Warning: %t@."
62 9094307a ploc
    Location.pp_loc loc
63
    pp_msg
64
65
let pp_error loc pp_msg =
66
  Format.eprintf "@.%a@.Error: @[<v 0>%t@]@."
67
    Location.pp_loc loc
68
    pp_msg
69
70