Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / error.ml @ 04a188ec

History | View | Annotate | Download (1.82 KB)

1
open Format
2

    
3

    
4
type ident = Lustre_types.ident
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
exception Error of Location.t * error_kind
16

    
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
  | LoadError _ -> 10
28

    
29

    
30
  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
  | AlgebraicLoop  -> assert false (* should have been handled yet *)
57
  | LoadError l -> 
58
    fprintf fmt
59
      "Load error: %s.@."
60
      l
61
     
62
let pp_warning loc pp_msg =
63
  Format.eprintf "%a@.Warning: %t@."
64
    Location.pp_loc loc
65
    pp_msg
66

    
67
let pp_error loc pp_msg =
68
  Format.eprintf "@.%a@.Error: @[<v 0>%t@]@.@?"
69
    Location.pp_loc loc
70
    pp_msg
71
    
72

    
73