]>
Commit | Line | Data |
---|---|---|
1eee94d3 GM |
1 | (* mcError.def provides an interface between the string handling modules. |
2 | ||
83ffe9cd | 3 | Copyright (C) 2015-2023 Free Software Foundation, Inc. |
1eee94d3 GM |
4 | Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. |
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 mcError ; | |
23 | ||
24 | ||
25 | FROM SYSTEM IMPORT BYTE ; | |
26 | FROM DynamicStrings IMPORT String ; | |
27 | ||
28 | TYPE | |
29 | error ; | |
30 | ||
31 | ||
32 | (* | |
33 | internalError - displays an internal error message together with the compiler source | |
34 | file and line number. | |
35 | This function is not buffered and is used when the compiler is about | |
36 | to give up. | |
37 | *) | |
38 | ||
39 | PROCEDURE internalError (a: ARRAY OF CHAR; file: ARRAY OF CHAR; line: CARDINAL) ; | |
40 | ||
41 | ||
42 | ||
43 | (* *************************************************************************** | |
44 | The following routines are used for normal syntax and semantic error reporting | |
45 | *************************************************************************** *) | |
46 | ||
47 | ||
48 | (* | |
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. | |
52 | *) | |
53 | ||
54 | PROCEDURE writeFormat0 (a: ARRAY OF CHAR) ; | |
55 | ||
56 | ||
57 | (* | |
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. | |
61 | *) | |
62 | ||
63 | PROCEDURE writeFormat1 (a: ARRAY OF CHAR; w: ARRAY OF BYTE) ; | |
64 | ||
65 | ||
66 | (* | |
67 | writeFormat2 - displays the module and line together with the encapsulated | |
68 | format strings. | |
69 | Used for simple error messages tied to the current token. | |
70 | *) | |
71 | ||
72 | PROCEDURE writeFormat2 (a: ARRAY OF CHAR; w1, w2: ARRAY OF BYTE) ; | |
73 | ||
74 | ||
75 | (* | |
76 | writeFormat3 - displays the module and line together with the encapsulated | |
77 | format strings. | |
78 | Used for simple error messages tied to the current token. | |
79 | *) | |
80 | ||
81 | PROCEDURE writeFormat3 (a: ARRAY OF CHAR; w1, w2, w3: ARRAY OF BYTE) ; | |
82 | ||
83 | ||
84 | (* | |
85 | newError - creates and returns a new error handle. | |
86 | *) | |
87 | ||
88 | PROCEDURE newError (atTokenNo: CARDINAL) : error ; | |
89 | ||
90 | ||
91 | (* | |
92 | newWarning - creates and returns a new error handle suitable for a warning. | |
93 | A warning will not stop compilation. | |
94 | *) | |
95 | ||
96 | PROCEDURE newWarning (atTokenNo: CARDINAL) : error ; | |
97 | ||
98 | ||
99 | (* | |
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. | |
102 | *) | |
103 | ||
104 | PROCEDURE chainError (atTokenNo: CARDINAL; e: error) : error ; | |
105 | ||
106 | ||
107 | (* | |
108 | errorFormat routines provide a printf capability for the error handle. | |
109 | *) | |
110 | ||
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) ; | |
116 | ||
117 | ||
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 | |
121 | the strings. | |
122 | *************************************************************************** *) | |
123 | ||
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) ; | |
130 | ||
131 | ||
132 | (* | |
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. | |
136 | *) | |
137 | ||
138 | PROCEDURE warnFormat0 (a: ARRAY OF CHAR) ; | |
139 | ||
140 | ||
141 | (* | |
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. | |
145 | *) | |
146 | ||
147 | PROCEDURE warnFormat1 (a: ARRAY OF CHAR; w: ARRAY OF BYTE) ; | |
148 | ||
149 | ||
150 | (* | |
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. | |
155 | *) | |
156 | ||
157 | PROCEDURE flushErrors ; | |
158 | ||
159 | ||
160 | (* | |
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 | |
165 | continue. | |
166 | *) | |
167 | ||
168 | PROCEDURE flushWarnings ; | |
169 | ||
170 | ||
171 | (* | |
172 | errorAbort0 - aborts compiling, it flushes all warnings and errors before aborting. | |
173 | *) | |
174 | ||
175 | PROCEDURE errorAbort0 (a: ARRAY OF CHAR) ; | |
176 | ||
177 | ||
178 | END mcError. |