]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/m2/gm2-compiler/M2Error.def
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / gm2-compiler / M2Error.def
CommitLineData
1eee94d3
GM
1(* M2Error.def error reporting interface.
2
a945c346 3Copyright (C) 2001-2024 Free Software Foundation, Inc.
1eee94d3
GM
4Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6This file is part of GNU Modula-2.
7
8GNU Modula-2 is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 3, or (at your option)
11any later version.
12
13GNU Modula-2 is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU Modula-2; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. *)
21
22DEFINITION MODULE M2Error ;
23
24(*
25 Title : M2Error
26 Author : Gaius Mulley
27 System : UNIX (gm2)
28 Description: provides an interface between the string handling modules
29 and the compiler.
30*)
31
32FROM SYSTEM IMPORT BYTE ;
33FROM DynamicStrings IMPORT String ;
34FROM NameKey IMPORT Name ;
35
36EXPORT QUALIFIED Error, ErrorScope,
37 InternalError,
38 WriteFormat0, WriteFormat1, WriteFormat2, WriteFormat3,
39 NewError, ErrorFormat0, ErrorFormat1, ErrorFormat2, ErrorFormat3,
40 ErrorString,
41 NewWarning, NewNote, SetColor,
42 FlushErrors, FlushWarnings, ChainError,
43 ErrorStringAt, ErrorStringAt2, ErrorStringsAt2,
44 WarnStringAt, WarnStringAt2, WarnStringsAt2,
45 ErrorAbort0,
46 WarnFormat0, WarnFormat1, MoveError,
47 AnnounceScope, EnterImplementationScope,
48 EnterModuleScope, EnterDefinitionScope, EnterProgramScope,
49 EnterProcedureScope, DepthScope, GetAnnounceScope,
50 DefaultProgramModule, DefaultImplementationModule,
51 DefaultDefinitionModule, DefaultInnerModule, DefaultProcedure,
52 EnterErrorScope, GetCurrentErrorScope, ResetErrorScope,
53 LeaveErrorScope ;
54
55
56TYPE
57 Error ;
58 ErrorScope ;
59
60
61(*
62 InternalError - displays an internal error message together with the compiler source
63 file and line number.
64 This function is not buffered and is used when the compiler is about
65 to give up.
66*)
67
68PROCEDURE InternalError (message: ARRAY OF CHAR) <* noreturn *> ;
69
70
71
72(* ***************************************************************************
73 The following routines are used for normal syntax and semantic error reporting
74 *************************************************************************** *)
75
76
77(*
78 WriteFormat0 - displays the source module and line together
79 with the encapsulated format string.
80 Used for simple error messages tied to the current token.
81*)
82
83PROCEDURE WriteFormat0 (a: ARRAY OF CHAR) ;
84
85
86(*
87 WriteFormat1 - displays the source module and line together
88 with the encapsulated format string.
89 Used for simple error messages tied to the current token.
90*)
91
92PROCEDURE WriteFormat1 (a: ARRAY OF CHAR; w: ARRAY OF BYTE) ;
93
94
95(*
96 WriteFormat2 - displays the module and line together with the encapsulated
97 format strings.
98 Used for simple error messages tied to the current token.
99*)
100
101PROCEDURE WriteFormat2 (a: ARRAY OF CHAR; w1, w2: ARRAY OF BYTE) ;
102
103
104(*
105 WriteFormat3 - displays the module and line together with the encapsulated
106 format strings.
107 Used for simple error messages tied to the current token.
108*)
109
110PROCEDURE WriteFormat3 (a: ARRAY OF CHAR; w1, w2, w3: ARRAY OF BYTE) ;
111
112
113(*
114 NewError - creates and returns a new error handle.
115*)
116
117PROCEDURE NewError (AtTokenNo: CARDINAL) : Error ;
118
119
120(*
121 NewWarning - creates and returns a new error handle suitable for a warning.
122 A warning will not stop compilation.
123*)
124
125PROCEDURE NewWarning (AtTokenNo: CARDINAL) : Error ;
126
127
128(*
129 NewNote - creates and returns a new error handle suitable for a note.
130 A note will not stop compilation.
131*)
132
133PROCEDURE NewNote (AtTokenNo: CARDINAL) : Error ;
134
135
136(*
137 ChainError - creates and returns a new error handle, this new error
138 is associated with, e, and is chained onto the end of, e.
139*)
140
141PROCEDURE ChainError (AtTokenNo: CARDINAL; e: Error) : Error ;
142
143
144(*
145 MoveError - repositions an error, e, to token, AtTokenNo, and returns, e.
146*)
147
148PROCEDURE MoveError (e: Error; AtTokenNo: CARDINAL) : Error ;
149
150
151(*
152 SetColor - informs the error module that this error will have had colors
153 assigned to it. If an error is issued without colors assigned
154 then the default colors will be assigned to the legacy error
155 messages.
156*)
157
158PROCEDURE SetColor (e: Error) : Error ;
159
160
161(*
162 ErrorFormat routines provide a printf capability for the error handle.
163*)
164
165PROCEDURE ErrorFormat0 (e: Error; a: ARRAY OF CHAR) ;
166PROCEDURE ErrorFormat1 (e: Error; a: ARRAY OF CHAR; w: ARRAY OF BYTE) ;
167PROCEDURE ErrorFormat2 (e: Error; a: ARRAY OF CHAR; w1, w2: ARRAY OF BYTE) ;
168PROCEDURE ErrorFormat3 (e: Error; a: ARRAY OF CHAR; w1, w2, w3: ARRAY OF BYTE) ;
169PROCEDURE ErrorString (e: Error; str: String) ;
170
171
172(* ***************************************************************************
173 The following routines are useful for positioning and warnings and errors
174 at tokens. The strings are emitted later, so the caller must not destroy
175 the strings.
176 *************************************************************************** *)
177
178PROCEDURE ErrorStringAt (s: String; tok: CARDINAL) ;
179PROCEDURE ErrorStringAt2 (s: String; tok1, tok2: CARDINAL) ;
180PROCEDURE ErrorStringsAt2 (s1, s2: String; tok1, tok2: CARDINAL) ;
181PROCEDURE WarnStringAt (s: String; tok: CARDINAL) ;
182PROCEDURE WarnStringAt2 (s: String; tok1, tok2: CARDINAL) ;
183PROCEDURE WarnStringsAt2 (s1, s2: String; tok1, tok2: CARDINAL) ;
184
185
186(*
187 WarnFormat0 - displays the source module and line together
188 with the encapsulated format string.
189 Used for simple warning messages tied to the current token.
190*)
191
192PROCEDURE WarnFormat0 (a: ARRAY OF CHAR) ;
193
194
195(*
196 WarnFormat1 - displays the source module and line together
197 with the encapsulated format string.
198 Used for simple warning messages tied to the current token.
199*)
200
201PROCEDURE WarnFormat1 (a: ARRAY OF CHAR; w: ARRAY OF BYTE) ;
202
203
204(*
205 FlushErrors - switches the output channel to the error channel
206 and then writes out all errors.
207 If an error is present the compilation is terminated.
208 All warnings are ignored.
209*)
210
211PROCEDURE FlushErrors ;
212
213
214(*
215 FlushWarnings - switches the output channel to the error channel
216 and then writes out all warnings.
217 If an error is present the compilation is terminated,
218 if warnings only were emitted then compilation will
219 continue.
220*)
221
222PROCEDURE FlushWarnings ;
223
224
225(*
226 ErrorAbort0 - aborts compiling, it flushes all warnings and errors before aborting.
227*)
228
1bd13193 229PROCEDURE ErrorAbort0 (a: ARRAY OF CHAR) <* noreturn *> ;
1eee94d3
GM
230
231
232(*
233 AnnounceScope - return the error string message with a scope description prepended
234 assuming that scope has changed.
235*)
236
237PROCEDURE AnnounceScope (e: Error; message: String) : String ;
238
239
240(*
241 EnterImplementationScope - signifies to the error routines that the front end
242 has started to compile implementation module scopeName.
243*)
244
245PROCEDURE EnterImplementationScope (scopename: Name) ;
246
247
248(*
249 EnterProgramScope - signifies to the error routines that the front end
250 has started to compile program module scopeName.
251*)
252
253PROCEDURE EnterProgramScope (scopename: Name) ;
254
255
256(*
257 EnterModuleScope - signifies to the error routines that the front end
258 has started to compile an inner module scopeName.
259*)
260
261PROCEDURE EnterModuleScope (scopename: Name) ;
262
263
264(*
265 EnterDefinitionScope - signifies to the error routines that the front end
266 has started to compile definition module scopeName.
267*)
268
269PROCEDURE EnterDefinitionScope (scopename: Name) ;
270
271
272(*
273 EnterProcedureScope - signifies to the error routines that the front end
274 has started to compile definition module scopeName.
275*)
276
277PROCEDURE EnterProcedureScope (scopename: Name) ;
278
279
280(*
281 DepthScope - returns the depth of the scope stack.
282*)
283
284PROCEDURE DepthScope () : CARDINAL ;
285
286
287(*
288 GetAnnounceScope - return message with the error scope attached to message.
289 filename and message are treated as read only by this
290 procedure function.
291*)
292
293PROCEDURE GetAnnounceScope (filename, message: String) : String ;
294
295
296(*
297 DefaultProgramModule - sets up an unnamed program scope before the Ident is seen.
298*)
299
300PROCEDURE DefaultProgramModule ;
301
302
303(*
304 DefaultImplementationModule - sets up an unnamed implementation
305 scope before the Ident is seen.
306*)
307
308PROCEDURE DefaultImplementationModule ;
309
310
311(*
312 DefaultDefinitionModule - sets up an unnamed definition
313 scope before the Ident is seen.
314*)
315
316PROCEDURE DefaultDefinitionModule ;
317
318
319(*
320 DefaultInnerModule - sets up an unnamed inner
321 scope before the Ident is seen.
322*)
323
324PROCEDURE DefaultInnerModule ;
325
326
327(*
328 DefaultProcedure - sets up an unnamed procedure
329 scope before the Ident is seen.
330*)
331
332PROCEDURE DefaultProcedure ;
333
334
335(*
336 EnterErrorScope - pushes the currentScope and sets currentScope to scope.
337*)
338
339PROCEDURE EnterErrorScope (scope: ErrorScope) ;
340
341
342(*
343 LeaveErrorScope - leave the current scope and pop into the previous one.
344*)
345
346PROCEDURE LeaveErrorScope ;
347
348
349(*
350 GetCurrentErrorScope - returns currentScope.
351*)
352
353PROCEDURE GetCurrentErrorScope () : ErrorScope ;
354
355
356(*
357 ResetErrorScope - should be called at the start of each pass to
358 reset the error scope index.
359*)
360
361PROCEDURE ResetErrorScope ;
362
363
364END M2Error.