~ubuntu-branches/debian/sid/frama-c/sid

« back to all changes in this revision

Viewing changes to cil/ocamlutil/errormsg.mli

  • Committer: Bazaar Package Importer
  • Author(s): Mehdi Dogguy
  • Date: 2009-06-03 08:19:25 UTC
  • Revision ID: james.westby@ubuntu.com-20090603081925-kihvxvt0wy3zc4ar
Tags: upstream-20081201.dfsg
Import upstream version 20081201.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(**************************************************************************)
 
2
(*                                                                        *)
 
3
(*  Copyright (C) 2001-2003,                                              *)
 
4
(*   George C. Necula    <necula@cs.berkeley.edu>                         *)
 
5
(*   Scott McPeak        <smcpeak@cs.berkeley.edu>                        *)
 
6
(*   Wes Weimer          <weimer@cs.berkeley.edu>                         *)
 
7
(*   Ben Liblit          <liblit@cs.berkeley.edu>                         *)
 
8
(*  All rights reserved.                                                  *)
 
9
(*                                                                        *)
 
10
(*  Redistribution and use in source and binary forms, with or without    *)
 
11
(*  modification, are permitted provided that the following conditions    *)
 
12
(*  are met:                                                              *)
 
13
(*                                                                        *)
 
14
(*  1. Redistributions of source code must retain the above copyright     *)
 
15
(*  notice, this list of conditions and the following disclaimer.         *)
 
16
(*                                                                        *)
 
17
(*  2. Redistributions in binary form must reproduce the above copyright  *)
 
18
(*  notice, this list of conditions and the following disclaimer in the   *)
 
19
(*  documentation and/or other materials provided with the distribution.  *)
 
20
(*                                                                        *)
 
21
(*  3. The names of the contributors may not be used to endorse or        *)
 
22
(*  promote products derived from this software without specific prior    *)
 
23
(*  written permission.                                                   *)
 
24
(*                                                                        *)
 
25
(*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   *)
 
26
(*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     *)
 
27
(*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS     *)
 
28
(*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE        *)
 
29
(*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,   *)
 
30
(*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  *)
 
31
(*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      *)
 
32
(*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER      *)
 
33
(*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT    *)
 
34
(*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN     *)
 
35
(*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE       *)
 
36
(*  POSSIBILITY OF SUCH DAMAGE.                                           *)
 
37
(*                                                                        *)
 
38
(*  File modified by CEA (Commissariat � l'�nergie Atomique).             *)
 
39
(**************************************************************************)
 
40
 
 
41
(*
 
42
 *
 
43
 * Copyright (c) 2001-2002, 
 
44
 *  George C. Necula    <necula@cs.berkeley.edu>
 
45
 *  Scott McPeak        <smcpeak@cs.berkeley.edu>
 
46
 *  Wes Weimer          <weimer@cs.berkeley.edu>
 
47
 * All rights reserved.
 
48
 * 
 
49
 * Redistribution and use in source and binary forms, with or without
 
50
 * modification, are permitted provided that the following conditions are
 
51
 * met:
 
52
 *
 
53
 * 1. Redistributions of source code must retain the above copyright
 
54
 * notice, this list of conditions and the following disclaimer.
 
55
 *
 
56
 * 2. Redistributions in binary form must reproduce the above copyright
 
57
 * notice, this list of conditions and the following disclaimer in the
 
58
 * documentation and/or other materials provided with the distribution.
 
59
 *
 
60
 * 3. The names of the contributors may not be used to endorse or promote
 
61
 * products derived from this software without specific prior written
 
62
 * permission.
 
63
 *
 
64
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 
65
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 
66
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 
67
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 
68
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
69
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
70
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
71
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
72
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
73
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
74
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
75
 *
 
76
 *)
 
77
(** Utility functions for error-reporting *)
 
78
 
 
79
(** A channel for printing log messages *)
 
80
val logChannel : out_channel ref
 
81
 
 
82
(** If set then print debugging info *)
 
83
val debugFlag  : bool ref               
 
84
 
 
85
val verboseFlag : bool ref
 
86
 
 
87
 
 
88
(** Set to true if you want to see all warnings. *)
 
89
val warnFlag: bool ref
 
90
 
 
91
(** Error reporting functions raise this exception *)
 
92
exception Error
 
93
 
 
94
 
 
95
   (* Error reporting. All of these functions take same arguments as a 
 
96
    * Pretty.eprintf. They set the hadErrors flag, but do not raise an 
 
97
    * exception. Their return type is unit.
 
98
    *)
 
99
 
 
100
(** Prints an error message of the form [Error: ...]. 
 
101
    Use in conjunction with s, for example: [E.s (E.error ... )]. *)
 
102
val error:         ('a,unit,Pretty.doc,unit) format4 -> 'a
 
103
 
 
104
(** Similar to [error] except that its output has the form [Bug: ...] *)
 
105
val bug:           ('a,unit,Pretty.doc,unit) format4 -> 'a
 
106
 
 
107
(** Similar to [error] except that its output has the form [Unimplemented: ...] *)
 
108
val unimp:         ('a,unit,Pretty.doc,unit) format4 -> 'a
 
109
 
 
110
(** Stop the execution by raising an Error. *)
 
111
val s:             'a -> 'b
 
112
 
 
113
(** This is set whenever one of the above error functions are called. It must
 
114
    be cleared manually *)
 
115
val hadErrors: bool ref  
 
116
 
 
117
(** Like {!Errormsg.error} but does not raise the {!Errormsg.Error} 
 
118
 * exception. Return type is unit. *)
 
119
val warn:    ('a,unit,Pretty.doc,unit) format4 -> 'a
 
120
 
 
121
(** Like {!Errormsg.warn} but optional. Printed only if the 
 
122
 * {!Errormsg.warnFlag} is set *)
 
123
val warnOpt: ('a,unit,Pretty.doc,unit) format4 -> 'a
 
124
 
 
125
(** Print something to [logChannel] *)
 
126
val log:           ('a,unit,Pretty.doc,unit) format4 -> 'a
 
127
 
 
128
(** same as {!Errormsg.log} but do not wrap lines *)
 
129
val logg:          ('a,unit,Pretty.doc,unit) format4 -> 'a
 
130
 
 
131
   (* All of the error and warning reporting functions can also print a 
 
132
    * context. To register a context printing function use "pushContext". To 
 
133
    * remove the last registered one use "popContext". If one of the error 
 
134
    * reporting functions is called it will invoke all currently registered 
 
135
    * context reporting functions in the reverse order they were registered. *)
 
136
 
 
137
(** Do not actually print (i.e. print to /dev/null) *)
 
138
val null : ('a,unit,Pretty.doc,unit) format4 -> 'a
 
139
 
 
140
(** Registers a context printing function *)
 
141
val pushContext  : (Format.formatter -> unit) -> unit
 
142
 
 
143
(** Removes the last registered context printing function *)
 
144
val popContext   : unit -> unit
 
145
 
 
146
(** Show the context stack to stderr *)
 
147
val showContext : unit -> unit
 
148
 
 
149
(** To ensure that the context is registered and removed properly, use the 
 
150
    function below *)
 
151
val withContext  : (Format.formatter -> unit) -> ('a -> 'b) -> 'a -> 'b
 
152
 
 
153
 
 
154
 
 
155
val newline: unit -> unit  (* Call this function to announce a new line *)
 
156
val newHline: unit -> unit 
 
157
 
 
158
val getPosition: unit -> Lexing.position * Lexing.position
 
159
val getHPosition: unit -> int * string (** high-level position *)
 
160
 
 
161
val setHLine: int -> unit
 
162
val setHFile: string -> unit
 
163
 
 
164
val setCurrentLine: int -> unit
 
165
val setCurrentFile: string -> unit
 
166
 
 
167
(** Type for source-file locations *)
 
168
type location = 
 
169
    { file: string; (** The file name *)
 
170
      line: int;    (** The line number *)
 
171
      hfile: string; (** The high-level file name, or "" if not present *)
 
172
      hline: int;    (** The high-level line number, or 0 if not present *)
 
173
    } 
 
174
 
 
175
val d_loc: unit -> location -> Pretty.doc
 
176
val d_hloc: unit -> location -> Pretty.doc
 
177
    
 
178
val getLocation: unit -> location
 
179
 
 
180
val parse_error: string -> (* A message *) 
 
181
                 'a
 
182
 
 
183
(** An unknown location for use when you need one but you don't have one *)
 
184
val locUnknown: location
 
185
 
 
186
 
 
187
(** Records whether the stdin is open for reading the goal **)
 
188
val readingFromStdin: bool ref
 
189
 
 
190
 
 
191
(* Call this function to start parsing. useBasename is by default "true", 
 
192
 * meaning that the error information maintains only the basename. If the 
 
193
 * file name is - then it reads from stdin. *)
 
194
val startParsing:  ?useBasename:bool -> string -> 
 
195
  Lexing.lexbuf 
 
196
 
 
197
val startParsingFromString: ?file:string -> ?line:int -> string
 
198
                            -> Lexing.lexbuf
 
199
 
 
200
val finishParsing: unit -> unit (* Call this function to finish parsing and 
 
201
                                 * close the input channel *)
 
202
 
 
203
 
 
204
(* This reference contains the first filename encountered in a #line directive.
 
205
   It is reset to [None]  by [startParsing*] functions.
 
206
*)
 
207
val first_filename_encountered: string option ref