]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-compiler/M2MetaError.def
481f818ad7c56fe1b9e6b84cbbe4ca9852e22d7b
[thirdparty/gcc.git] / gcc / m2 / gm2-compiler / M2MetaError.def
1 (* M2MetaError.def provides a set of high level error routines.
2
3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
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 M2MetaError ;
23
24 (*
25 Title : M2MetaError
26 Author : Gaius Mulley
27 System : GNU Modula-2
28 Date : Tue Oct 14 12:11:13 2008
29 Revision : $Version$
30 Description: provides a set of high level error routines. These
31 routines utilise M2Error and provides the programmer
32 with an easier method to obtain useful symbol table
33 information.
34 *)
35
36 FROM DynamicStrings IMPORT String ;
37 FROM NameKey IMPORT Name ;
38
39 EXPORT QUALIFIED MetaError0, MetaError1, MetaError2, MetaError3, MetaError4,
40 MetaErrors1, MetaErrors2, MetaErrors3, MetaErrors4,
41 MetaErrorT0, MetaErrorT1, MetaErrorT2, MetaErrorT3, MetaErrorT4,
42 MetaErrorsT1, MetaErrorsT2, MetaErrorsT3, MetaErrorsT4,
43 MetaErrorString0,
44 MetaErrorString1, MetaErrorString2, MetaErrorString3,
45 MetaErrorString4,
46 MetaErrorStringT0, MetaErrorStringT1, MetaErrorStringT2,
47 MetaErrorStringT3, MetaErrorStringT4,
48 MetaErrorN1, MetaErrorN2, MetaErrorNT0, MetaErrorNT1, MetaErrorNT2,
49 MetaString0, MetaString1, MetaString2, MetaString3, MetaString4 ;
50
51
52 (*
53 All the procedures below expect the s, s1, s2, s3, s4 to be symbols
54 and m, m1, m2, m3 are error messages and format specifiers.
55 By default all substitutions are enclosed in quotes. However there
56 are a few format modifiers which disable quotations.
57 The format specifiers are:
58
59 {%1a} symbol name for the first symbol.
60 {%1q} qualified name for the first symbol.
61 {%1t} type name for the first symbol.
62 {%1ts} skips type pseudonyms.
63 {%1d} symbol description
64 {%1td} type name or symbol description
65 {%1Td} get the type of the first symbol and describe it.
66 {%1Sd} skip the type pseudonyms of the first symbol and describe it.
67 {%1ua} force no quotes after substituting the text.
68
69 {%1D} sets the error message to where symbol 1 was declared.
70 The declaration will choose the definition module, then
71 implementation (or program) module.
72 {%1M} sets the error message to where symbol 1 was declared.
73 The declaration will choose the implementation or program
74 module and if these do not exist then it falls back to
75 the definition module.
76 {%1U} sets the error message to where symbol 1 was first used.
77 {%A} abort, issue non recoverable error message (this should
78 not used for internal errors).
79 {%E} error (default recoverable error).
80 {%W} message is a warning, not an error.
81 {%O} message is a note, not an error.
82 {%Kword} the string word is quoted and rendered as a keyword.
83 {%kword} the string word is unquoted and rendered as a keyword.
84 {%C} chain this error on the previous rooted error.
85 {%R} this error will be the root of the future chained errors.
86 {%n} decimal number. Not quoted.
87 {%N} count (number), for example, 1st, 2nd, 3rd, 4th. Not quoted.
88 {%X} push contents of the output string onto the string stack.
89 {%Yname} place contents of dictionary entry name onto the output string.
90 {%Zname} replace dictionary entry name for the output string.
91 Pop contents of the string stack onto the output string.
92 {%Q} remove all entries in the dictionary.
93 {%P} push the current color state.
94 {%p} pop the current color state.
95 {%Ffilename} the string filename will be rendered using the filename color.
96 {%ccolor} change color into one of: none, fixit-delete, fixit-insert,
97 locus, filename, type, error, warning, note.
98 %< open quote and color.
99 %> close quote and color.
100 %% %
101 %{ {
102 %} }
103 the error messages may also embed optional strings such as:
104
105 {%1a:this string is emitted if the symbol name is non null}
106 {!%1a:this string is emitted if the symbol name is null}
107 {!%1a:{%1d}}
108 if the symbol name does not exist then print a description
109 of the symbol.
110 {%1atd} was incompatible with the return type of the procedure
111 means print the symbol name (if null then print the type name
112 if null then print out the description) followed by the
113 string "was incompatible with the return type of the procedure"
114
115 Note all replaced names or descriptions are enclosed in quotes, like:
116 'foo', which matches the behaviour of gcc. Also note temporary names
117 are treated as null. Finally the order of format specifiers does
118 matter, {%1td} means get type name and use it if non null, otherwise
119 describe the symbol. If ordinary text is copied then it is not quoted.
120
121 The color strings are: "filename", "quote", "error", "warning", "note",
122 "locus", "insert", "delete", "type", "range1", range2".
123 *)
124
125 (*
126 ebnf := { percent | lbra | any } =:
127
128 percent := '%' anych =:
129
130 lbra := '{' [ '!' ] percenttoken '}' =:
131
132 percenttoken := '%' ( '1' op | '2' op | '3' op | '4' op ) =:
133
134 op := {'a'|'q'|'t'|'d'|'n'|'s'|'D'|'U'|'E'|'W'} then =:
135
136 then := [ ':' ebnf ] =:
137 *)
138
139 PROCEDURE MetaError0 (m: ARRAY OF CHAR) ;
140 PROCEDURE MetaError1 (m: ARRAY OF CHAR; s: CARDINAL) ;
141 PROCEDURE MetaError2 (m: ARRAY OF CHAR; s1, s2: CARDINAL) ;
142 PROCEDURE MetaError3 (m: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
143 PROCEDURE MetaError4 (m: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
144
145 PROCEDURE MetaErrors1 (m1, m2: ARRAY OF CHAR; s: CARDINAL) ;
146 PROCEDURE MetaErrors2 (m1, m2: ARRAY OF CHAR; s1, s2: CARDINAL) ;
147 PROCEDURE MetaErrors3 (m1, m2: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
148 PROCEDURE MetaErrors4 (m1, m2: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
149
150 PROCEDURE MetaErrorT0 (tok: CARDINAL; m: ARRAY OF CHAR) ;
151 PROCEDURE MetaErrorT1 (tok: CARDINAL; m: ARRAY OF CHAR; s: CARDINAL) ;
152 PROCEDURE MetaErrorT2 (tok: CARDINAL; m: ARRAY OF CHAR; s1, s2: CARDINAL) ;
153 PROCEDURE MetaErrorT3 (tok: CARDINAL; m: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
154 PROCEDURE MetaErrorT4 (tok: CARDINAL; m: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
155
156 PROCEDURE MetaErrorsT1 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s: CARDINAL) ;
157 PROCEDURE MetaErrorsT2 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s1, s2: CARDINAL) ;
158 PROCEDURE MetaErrorsT3 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s1, s2, s3: CARDINAL) ;
159 PROCEDURE MetaErrorsT4 (tok: CARDINAL; m1, m2: ARRAY OF CHAR; s1, s2, s3, s4: CARDINAL) ;
160
161 PROCEDURE MetaErrorString0 (m: String) ;
162 PROCEDURE MetaErrorString1 (m: String; s: CARDINAL) ;
163 PROCEDURE MetaErrorString2 (m: String; s1, s2: CARDINAL) ;
164 PROCEDURE MetaErrorString3 (m: String; s1, s2, s3: CARDINAL) ;
165 PROCEDURE MetaErrorString4 (m: String; s1, s2, s3, s4: CARDINAL) ;
166
167 PROCEDURE MetaErrorStringT0 (tok: CARDINAL; m: String) ;
168 PROCEDURE MetaErrorStringT1 (tok: CARDINAL; m: String; s: CARDINAL) ;
169 PROCEDURE MetaErrorStringT2 (tok: CARDINAL; m: String; s1, s2: CARDINAL) ;
170 PROCEDURE MetaErrorStringT3 (tok: CARDINAL; m: String; s1, s2, s3: CARDINAL) ;
171 PROCEDURE MetaErrorStringT4 (tok: CARDINAL; m: String; s1, s2, s3, s4: CARDINAL) ;
172
173 PROCEDURE MetaErrorN1 (m: ARRAY OF CHAR; n: Name) ;
174 PROCEDURE MetaErrorN2 (m: ARRAY OF CHAR; n1, n2: Name) ;
175 PROCEDURE MetaErrorNT0 (tok: CARDINAL; format: ARRAY OF CHAR) ;
176 PROCEDURE MetaErrorNT1 (tok: CARDINAL; format: ARRAY OF CHAR; name: Name) ;
177 PROCEDURE MetaErrorNT2 (tok: CARDINAL; format: ARRAY OF CHAR; name1, name2: Name) ;
178
179 PROCEDURE MetaString0 (m: String) : String ;
180 PROCEDURE MetaString1 (m: String; s: CARDINAL) : String ;
181 PROCEDURE MetaString2 (m: String; s1, s2: CARDINAL) : String ;
182 PROCEDURE MetaString3 (m: String; s1, s2, s3: CARDINAL) : String ;
183 PROCEDURE MetaString4 (m: String; s1, s2, s3, s4: CARDINAL) : String ;
184
185 END M2MetaError.