Debian Codegraph @

gcc/m2/gm2-compiler/M2MetaError.def

raw
1 (* M2MetaError.def provides a set of high level error routines.
2
3 Copyright (C) 2008-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
21
22 DEFINITION MODULE M2MetaError ;
23
24 (* Provides a set of high level error routines using format specifiers. *)
25
26 FROM DynamicStrings IMPORT String ;
27 FROM NameKey IMPORT Name ;
28
29
30 (*
31 All the procedures below expect the s, s1, s2, s3, s4 to be symbols
32 and m, m1, m2, m3 are error messages and format specifiers.
33 By default all substitutions are enclosed in quotes. However there
34 are a few format modifiers which disable quotations.
35 The format specifiers are:
36
37 {%1a} symbol name for the first symbol.
38 {%1q} qualified name for the first symbol.
39 {%1t} type name for the first symbol.
40 {%1ts} skips type pseudonyms.
41 {%1d} symbol description
42 {%1td} type name or symbol description
43 {%1Td} get the type of the first symbol and describe it.
44 {%1Sd} skip the type pseudonyms of the first symbol and describe it.
45 {%1ua} force no quotes after substituting the text.
46
47 {%1D} sets the error message to where symbol 1 was declared.
48 The declaration will choose the definition module, then
49 implementation (or program) module.
50 {%1G} sets the error message to where symbol 1 was declared.
51 The declaration will choose in order the forward declaration,
52 implementation module, program module or definition module.
53 {%1M} sets the error message to where symbol 1 was declared.
54 The declaration will choose the implementation or program
55 module and if these do not exist then it falls back to
56 the definition module.
57 {%1U} sets the error message to where symbol 1 was first used.
58 {%1V} set the error message location to the name of the symbol declared.
59 For example foo: bar
60 ^^^ some error message.
61 {%1H} set the error message location to the whole declaration of the symbol.
62 For example foo: bar
63 ^^^^^^^^ some error message.
64 {%1B} set the error message location to the type declaration of the symbol.
65 For example foo: bar
66 ^^^ some error message.
67 {%A} abort, issue non recoverable error message (this should
68 not used for internal errors).
69 {%E} error (default recoverable error).
70 {%W} message is a warning, not an error.
71 {%O} message is a note, not an error.
72 {%Kword} the string word is quoted and rendered as a keyword.
73 {%kword} the string word is unquoted and rendered as a keyword.
74 {%C} chain this error on the previous rooted error.
75 {%R} this error will be the root of the future chained errors.
76 {% n} decimal number. Not quoted. There is no space between the
77 % and n (this has been added to hide this comment from gettext).
78 {%N} count (number), for example, 1st, 2nd, 3rd, 4th. Not quoted.
79 {%X} push contents of the output string onto the string stack.
80 {%Yname} place contents of dictionary entry name onto the output string.
81 {%Zname} replace dictionary entry name for the output string.
82 Pop contents of the string stack onto the output string.
83 {%Q} remove all entries in the dictionary.
84 {%P} push the current color state.
85 {%p} pop the current color state.
86 {%Ffilename} the string filename will be rendered using the filename color.
87 {%ccolor} change color into one of: none, fixit-delete, fixit-insert,
88 locus, filename, type, error, warning, note.
89 %< open quote and color.
90 %> close quote and color.
91 %% %
92 %{ {
93 %} }
94 the error messages may also embed optional strings such as:
95
96 {%1a:this string is emitted if the symbol name is null}
97 {!%1a:this string is emitted if the symbol name is non null}
98 {%1a:{%1d}}
99 if the symbol name does not exist then print a description
100 of the symbol.
101 {%1atd} was incompatible with the return type of the procedure
102 means print the symbol name (if null then print the type name
103 if null then print out the description) followed by the
104 string "was incompatible with the return type of the procedure"
105
106 Note all replaced names or descriptions are enclosed in quotes, like:
107 'foo', which matches the behaviour of gcc. Also note temporary names
108 are treated as null. Finally the order of format specifiers does
109 matter, {%1td} means get type name and use it if non null, otherwise
110 describe the symbol. If ordinary text is copied then it is not quoted.
111
112 The color strings are: "filename", "quote", "error", "warning", "note",
113 "locus", "insert", "delete", "type", "range1",
114 "range2".
115 *)
116
117 (*
118 ebnf := { percent | lbra | any } =:
119
120 percent := '%' anych =:
121
122 lbra := '{' [ '!' ] percenttoken '}' =:
123
124 percenttoken := '%' ( '1' op | '2' op | '3' op | '4' op ) =:
125
126 op := {'a'|'q'|'t'|'d'|'n'|'s'|'D'|'U'|'E'|'W'} then =:
127
128 then := [ ':' ebnf ] =:
129 *)
130
131 PROCEDURE MetaError0 (m: ARRAY OF CHAR) ;
132 PROCEDURE MetaError1 (m: ARRAY OF CHAR; s: CARDINAL) ;
133 PROCEDURE MetaError2 (m: ARRAY OF CHAR; s1, s2: CARDINAL) ;
134 PROCEDURE MetaError3 (m: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
135 PROCEDURE MetaError4 (m: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
136
137 PROCEDURE MetaErrors1 (m1, m2: ARRAY OF CHAR; s: CARDINAL) ;
138 PROCEDURE MetaErrors2 (m1, m2: ARRAY OF CHAR; s1, s2: CARDINAL) ;
139 PROCEDURE MetaErrors3 (m1, m2: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
140 PROCEDURE MetaErrors4 (m1, m2: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
141
142 PROCEDURE MetaErrorT0 (tok: CARDINAL; m: ARRAY OF CHAR) ;
143 PROCEDURE MetaErrorT1 (tok: CARDINAL; m: ARRAY OF CHAR; s: CARDINAL) ;
144 PROCEDURE MetaErrorT2 (tok: CARDINAL; m: ARRAY OF CHAR; s1, s2: CARDINAL) ;
145 PROCEDURE MetaErrorT3 (tok: CARDINAL; m: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
146 PROCEDURE MetaErrorT4 (tok: CARDINAL; m: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
147
148 PROCEDURE MetaErrorsT1 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s: CARDINAL) ;
149 PROCEDURE MetaErrorsT2 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s1, s2: CARDINAL) ;
150 PROCEDURE MetaErrorsT3 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
151 PROCEDURE MetaErrorsT4 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
152
153 PROCEDURE MetaErrorString0 (m: String) ;
154 PROCEDURE MetaErrorString1 (m: String; s: CARDINAL) ;
155 PROCEDURE MetaErrorString2 (m: String; s1, s2: CARDINAL) ;
156 PROCEDURE MetaErrorString3 (m: String; s1, s2, s3: CARDINAL) ;
157 PROCEDURE MetaErrorString4 (m: String; s1, s2, s3, s4: CARDINAL) ;
158
159 PROCEDURE MetaErrorStringT0 (tok: CARDINAL; m: String) ;
160 PROCEDURE MetaErrorStringT1 (tok: CARDINAL; m: String; s: CARDINAL) ;
161 PROCEDURE MetaErrorStringT2 (tok: CARDINAL; m: String; s1, s2: CARDINAL) ;
162 PROCEDURE MetaErrorStringT3 (tok: CARDINAL; m: String; s1, s2, s3: CARDINAL) ;
163 PROCEDURE MetaErrorStringT4 (tok: CARDINAL; m: String; s1, s2, s3, s4: CARDINAL) ;
164
165 PROCEDURE MetaErrorN1 (m: ARRAY OF CHAR; n: Name) ;
166 PROCEDURE MetaErrorN2 (m: ARRAY OF CHAR; n1, n2: Name) ;
167 PROCEDURE MetaErrorNT0 (tok: CARDINAL; format: ARRAY OF CHAR) ;
168 PROCEDURE MetaErrorNT1 (tok: CARDINAL; format: ARRAY OF CHAR; name: Name) ;
169 PROCEDURE MetaErrorNT2 (tok: CARDINAL; format: ARRAY OF CHAR; name1, name2: Name) ;
170
171 PROCEDURE MetaString0 (m: String) : String ;
172 PROCEDURE MetaString1 (m: String; s: CARDINAL) : String ;
173 PROCEDURE MetaString2 (m: String; s1, s2: CARDINAL) : String ;
174 PROCEDURE MetaString3 (m: String; s1, s2, s3: CARDINAL) : String ;
175 PROCEDURE MetaString4 (m: String; s1, s2, s3, s4: CARDINAL) : String ;
176
177
178 (*
179 MetaErrorDecl - if sym is a variable or parameter then generate a
180 declaration error or warning message. If error is
181 FALSE then a warning is issued.
182 *)
183
184 PROCEDURE MetaErrorDecl (sym: CARDINAL; error: BOOLEAN) ;
185
186
187 END M2MetaError.