Project

General

Profile

« Previous | Next » 

Revision ca7ff3f7

Added by LĂ©lio Brun 8 months ago

reformatting

View differences:

src/error.ml
1 1
open Format
2 2

  
3

  
4 3
type ident = Lustre_types.ident
4

  
5 5
type error_kind =
6
    Main_not_found
6
  | Main_not_found
7 7
  | Main_wrong_kind
8 8
  | No_main_specified
9 9
  | Unbound_symbol of ident
......
12 12
  | Wrong_number of ident
13 13
  | AlgebraicLoop
14 14
  | LoadError of string
15

  
15 16
exception Error of Location.t * error_kind
16 17

  
17 18
let return_code kind =
18 19
  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

  
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
29 38

  
30
  let pp_error_msg fmt = function
39
let pp_error_msg fmt = function
31 40
  | Main_not_found ->
32
      fprintf fmt "Could not find the definition of main node %s.@."
33
	!Global.main_node
41
    fprintf fmt "Could not find the definition of main node %s.@."
42
      !Global.main_node
34 43
  | Main_wrong_kind ->
35
    fprintf fmt
36
      "Node %s does not correspond to a valid main node definition.@." 
37
      !Global.main_node 
44
    fprintf fmt "Node %s does not correspond to a valid main node definition.@."
45
      !Global.main_node
38 46
  | No_main_specified ->
39 47
    fprintf fmt "No main node specified (use -node option)@."
40 48
  | 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
49
    fprintf fmt "%s is undefined.@." sym
50
  | Already_bound_symbol sym ->
51
    fprintf fmt "%s is already defined.@." sym
48 52
  | Unknown_library sym ->
49 53
    fprintf fmt
50
      "impossible to load library %s.lusic.@.Please compile the corresponding interface or source file.@."
54
      "impossible to load library %s.lusic.@.Please compile the corresponding \
55
       interface or source file.@."
51 56
      sym
52 57
  | Wrong_number sym ->
53 58
    fprintf fmt
54
      "library %s.lusic has a different version number and may crash compiler.@.Please recompile the corresponding interface or source file.@."
59
      "library %s.lusic has a different version number and may crash \
60
       compiler.@.Please recompile the corresponding interface or source \
61
       file.@."
55 62
      sym
56
  | AlgebraicLoop  -> assert false (* should have been handled yet *)
57
  | LoadError l -> 
58
    fprintf fmt
59
      "Load error: %s.@."
60
      l
61
     
63
  | AlgebraicLoop ->
64
    assert false (* should have been handled yet *)
65
  | LoadError l ->
66
    fprintf fmt "Load error: %s.@." l
67

  
62 68
let pp_warning loc pp_msg =
63
  Format.eprintf "%a@.Warning: %t@."
64
    Location.pp_loc loc
65
    pp_msg
69
  Format.eprintf "%a@.Warning: %t@." Location.pp_loc loc pp_msg
66 70

  
67 71
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
    
72
  Format.eprintf "@.%a@.Error: @[<v 0>%t@]@.@?" Location.pp_loc loc pp_msg

Also available in: Unified diff