module Reporting_basic:Basic error reportingsig
..end
Reporting_basic
contains functions to report errors and warnings.
It contains functions to print locations (Ast.l
) and lexing positions.
Despite Ast
it should not depend on any other Lem-file. This guarentees that
it can be used throughout the whole devolpment.
The main functionality is reporting errors. This is done by raising a
Fatal_error
exception. This is catched inside Lem and reported via report_error
.
There are several predefined types of errors which all cause different error
messages. If none of these fit, Err_general
can be used.
Reporting functions that need access to parts of the Lem development like
Typed_ast
are collected in Reporting
.
val loc_to_string : bool -> Ast.l -> string
loc_to_string short l
formats l
as a string. If short
is set, only the
most originating location is formated, not what methods transformed l
.val print_err : bool -> bool -> bool -> Ast.l -> string -> string -> unit
print_err fatal print_loc_source print_only_first_loc l head mes
prints an error / warning message to
std-err. It starts with printing location information stored in l
. If
print_loc_source
is set, the original input described by l
is retrieved and shown.
It then prints "head: mes". If fatal
is set, the program exists with error-code 1 afterwards.val debug_flag : bool Pervasives.ref
val print_debug : string -> unit
print_debug s
prints the string s
with some debug prefix to the standard error output.type
error =
| |
Err_general of |
(* | General errors, used for multi purpose. If you are unsure, use this one. | *) |
| |
Err_unreachable of |
(* | Unreachable errors should never be thrown. It means that some code was excuted that the programmer thought of as unreachable | *) |
| |
Err_todo of |
(* | Err_todo indicates that some feature is unimplemented. Normally,
it should be build using err_todo in order simplify searching
for occorences in the source code. | *) |
| |
Err_trans of |
|||
| |
Err_trans_header of |
|||
| |
Err_syntax of |
|||
| |
Err_syntax_locn of |
|||
| |
Err_lex of |
|||
| |
Err_type of |
(* | A typechecking error | *) |
| |
Err_internal of |
|||
| |
Err_rename of |
|||
| |
Err_cyclic_build of |
(* | resolving module dependencies detected a cyclic dependency of the given module | *) |
| |
Err_cyclic_inline of |
(* | Err_cyclic_inline l target const means that the inline of some constant const is cyclic for target target | *) |
| |
Err_resolve_dependency of |
(* | could not find a Module that should be imported in given list of directories | *) |
| |
Err_reorder_dependency of |
(* | Err_reorder_dependency (l, m) module m is needed at location l , but not allowed to be imported, because this
would require reording the user input | *) |
| |
Err_fancy_pattern_constant of |
(* | a constant occouring in a pattern has a fancy target-representation, that cannot be dealt with for patterns | *) |
Err_todo
should not be used directly, but only through err_todo
in order to make search easier.
Errors usually have location information and a message attached. Some also carry a boolean flag indicating,
the original source corresponding to the location information should be looked up and printed.
exception Fatal_error of error
Fatal_error
exception instead of
calling a report-function.val err_todo : bool -> Ast.l -> string -> exn
err_todo b l m
is an abreviatiation for Fatal_error (Err_todo (b, l, m))
val err_general : bool -> Ast.l -> string -> exn
err_general b l m
is an abreviatiation for Fatal_error (Err_general (b, l, m))
val err_unreachable : Ast.l -> string -> exn
err_unreachable l m
is an abreviatiation for Fatal_error (Err_unreachable (l, m))
val err_type : Ast.l -> string -> exn
err_type l msg
is an abreviatiation for Fatal_error (Err_type (l, m)
, i.e. for a general type-checking error
at location l
with error message msg
.val err_type_pp : Ast.l -> string -> (Format.formatter -> 'a -> unit) -> 'a -> exn
err_type l msg pp n
is similar to err_type
. However it uses the formatter pp
to format n
, resulting
in a string label
. The error message then has the form label : msg
.val report_error : error -> 'a
Fatal_error
exception is recommended.