Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 121 lines (89 sloc) 3.792 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (**
19 Error management for Qml.
20
21 @author Mathieu Barbin
22 @author Quentin Bourgerie
23 *)
24
25 (** {6 Design note} *)
26
27 (**
28 This module is meant to factorize code to create located error messages, for a
29 public or an internal audience.
30
31 This module uses internally the [passlib] which offers the opportunity to passes
32 and checkers to be more verbose and outputting a detailed context in the
33 track system, which can be analyzed after the compilation (or after the last error),
34 using [opatrack].
35 *)
36
37 (** {6 Context} *)
38
39 module Context :
40 sig
41
42 (** The type of the context of the error. *)
43 type context
44
45 (** Merging several context *)
46 val merge2 : context -> context -> context
47 val merge : context -> context list -> context
48
49 (** {6 Constructors} *)
50
51 (**
52 Should be enough in the majority of cases for outputting a public error message.
53 *)
54
55 val pos : FilePos.pos -> context
56 val label : Annot.label -> context
57
58 (**
59 Currently, we are waiting for refactoring about positions,
60 and we do not have them in many cases.
61 So, waiting for this refactoring, you can try to give the annotmap
62 and an expression, which should be enough in most of passes to get the
63 position.
64 *)
65
66 val annoted_expr : QmlAst.annotmap -> QmlAst.expr -> context
67 val annoted_pat : QmlAst.annotmap -> QmlAst.pat -> context
68
69 val annotmap : QmlAst.annotmap -> context
70
71 val code_elt : QmlAst.code_elt -> context
72
73 val expr : QmlAst.expr -> context
74 val exprs : QmlAst.expr -> QmlAst.expr list -> context
75
76 val pat : QmlAst.pat -> context
77
78 val ty : QmlAst.ty -> context
79
da48a00 @OpaOnWindowsNow [enhance] QmlError.Context: add a construtor for package context with…
OpaOnWindowsNow authored
80 val package : string -> context
81
fccc685 Initial open-source release
MLstate authored
82 (**
83 Sometimes, somebody is too lazy for refactoring code so
84 that he can build a correct context.
85 In this case, he should shame, and provide the absolute path
86 to the function in the source code where is built the context.
87 ["Module.SubModule.function:extra?"].
88 What a shame !
89 *)
90 val shame_on_me_i_am_too_lazy : string -> context
91
92 (** {b Descr}: Returns the source position recorded in the context. *)
93 val get_pos : context -> FilePos.pos
94 end
95
96 (**
97 The documentation of these function is in [PassHandler] and [PassError]
98 *)
99
100 (** {6 Interaction with Checkers} *)
101
102 type context = Context.context
103 (** *)
104 val check_fail : PassHandler.cond_id -> context -> ('a, 'error) OManager.oformat -> 'a
105 val scheck_fail : PassHandler.cond_id -> context -> ('a, unit) OManager.oformat -> 'a
106
107 (** {6 Interaction with Passes} *)
108
109 (** Internal Errors *)
110 (** *)
111 val cond_violation : PassHandler.cond_id -> context -> ('a, 'error) OManager.oformat -> 'a
112 val scond_violation : PassHandler.cond_id -> context -> ('a, unit) OManager.oformat -> 'a
113 val i_error : PassHandler.cond_id option -> context -> ('a, 'error) OManager.oformat -> 'a
114 val i_serror : PassHandler.cond_id option -> context -> ('a, unit) OManager.oformat -> 'a
115
116 (** Public Errors *)
117 (** *)
118 val error : context -> ('params, 'exit) OManager.oformat -> 'params
119 val serror : context -> ('params, unit) OManager.oformat -> 'params
120 val warning : wclass:WarningClass.wclass -> context -> ('params, unit) OManager.oformat -> 'params
Something went wrong with that request. Please try again.