Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / lib / error.ml @ 9b0432bc

History | View | Annotate | Download (1.82 KB)

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