1 (* mcError.def provides an interface between the string handling modules.
3 Copyright (C) 2015-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
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)
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.
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/>. *)
22 DEFINITION MODULE mcError
;
25 FROM SYSTEM
IMPORT BYTE
;
26 FROM DynamicStrings
IMPORT String
;
33 internalError - displays an internal error message together with the compiler source
35 This function is not buffered and is used when the compiler is about
39 PROCEDURE internalError (a
: ARRAY OF CHAR; file
: ARRAY OF CHAR; line
: CARDINAL) ;
43 (* ***************************************************************************
44 The following routines are used for normal syntax and semantic error reporting
45 *************************************************************************** *)
49 writeFormat0 - displays the source module and line together
50 with the encapsulated format string.
51 Used for simple error messages tied to the current token.
54 PROCEDURE writeFormat0 (a
: ARRAY OF CHAR) ;
58 writeFormat1 - displays the source module and line together
59 with the encapsulated format string.
60 Used for simple error messages tied to the current token.
63 PROCEDURE writeFormat1 (a
: ARRAY OF CHAR; w
: ARRAY OF BYTE
) ;
67 writeFormat2 - displays the module and line together with the encapsulated
69 Used for simple error messages tied to the current token.
72 PROCEDURE writeFormat2 (a
: ARRAY OF CHAR; w1
, w2
: ARRAY OF BYTE
) ;
76 writeFormat3 - displays the module and line together with the encapsulated
78 Used for simple error messages tied to the current token.
81 PROCEDURE writeFormat3 (a
: ARRAY OF CHAR; w1
, w2
, w3
: ARRAY OF BYTE
) ;
85 newError - creates and returns a new error handle.
88 PROCEDURE newError (atTokenNo
: CARDINAL) : error
;
92 newWarning - creates and returns a new error handle suitable for a warning.
93 A warning will not stop compilation.
96 PROCEDURE newWarning (atTokenNo
: CARDINAL) : error
;
100 chainError - creates and returns a new error handle, this new error
101 is associated with, e, and is chained onto the end of, e.
104 PROCEDURE chainError (atTokenNo
: CARDINAL; e
: error
) : error
;
108 errorFormat routines provide a printf capability for the error handle.
111 PROCEDURE errorFormat0 (e
: error
; a
: ARRAY OF CHAR) ;
112 PROCEDURE errorFormat1 (e
: error
; a
: ARRAY OF CHAR; w
: ARRAY OF BYTE
) ;
113 PROCEDURE errorFormat2 (e
: error
; a
: ARRAY OF CHAR; w1
, w2
: ARRAY OF BYTE
) ;
114 PROCEDURE errorFormat3 (e
: error
; a
: ARRAY OF CHAR; w1
, w2
, w3
: ARRAY OF BYTE
) ;
115 PROCEDURE errorString (e
: error
; str
: String
) ;
118 (* ***************************************************************************
119 The following routines are useful for positioning and warnings and errors
120 at tokens. The strings are emitted later, so the caller must not destroy
122 *************************************************************************** *)
124 PROCEDURE errorStringAt (s
: String
; tok
: CARDINAL) ;
125 PROCEDURE errorStringAt2 (s
: String
; tok1
, tok2
: CARDINAL) ;
126 PROCEDURE errorStringsAt2 (s1
, s2
: String
; tok1
, tok2
: CARDINAL) ;
127 PROCEDURE warnStringAt (s
: String
; tok
: CARDINAL) ;
128 PROCEDURE warnStringAt2 (s
: String
; tok1
, tok2
: CARDINAL) ;
129 PROCEDURE warnStringsAt2 (s1
, s2
: String
; tok1
, tok2
: CARDINAL) ;
133 warnFormat0 - displays the source module and line together
134 with the encapsulated format string.
135 Used for simple warning messages tied to the current token.
138 PROCEDURE warnFormat0 (a
: ARRAY OF CHAR) ;
142 warnFormat1 - displays the source module and line together
143 with the encapsulated format string.
144 Used for simple warning messages tied to the current token.
147 PROCEDURE warnFormat1 (a
: ARRAY OF CHAR; w
: ARRAY OF BYTE
) ;
151 flushErrors - switches the output channel to the error channel
152 and then writes out all errors.
153 If an error is present the compilation is terminated.
154 All warnings are ignored.
157 PROCEDURE flushErrors
;
161 flushWarnings - switches the output channel to the error channel
162 and then writes out all warnings.
163 If an error is present the compilation is terminated,
164 if warnings only were emitted then compilation will
168 PROCEDURE flushWarnings
;
172 errorAbort0 - aborts compiling, it flushes all warnings and errors before aborting.
175 PROCEDURE errorAbort0 (a
: ARRAY OF CHAR) ;