Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2MetaError. */
2 : : /* M2MetaError.mod provides a set of high level error routines.
3 : :
4 : : Copyright (C) 2008-2025 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include "gcc-consolidation.h"
26 : :
27 : : #include <stdbool.h>
28 : : # if !defined (PROC_D)
29 : : # define PROC_D
30 : : typedef void (*PROC_t) (void);
31 : : typedef struct { PROC_t proc; } PROC;
32 : : # endif
33 : :
34 : : # if !defined (TRUE)
35 : : # define TRUE (1==1)
36 : : # endif
37 : :
38 : : # if !defined (FALSE)
39 : : # define FALSE (1==0)
40 : : # endif
41 : :
42 : : # include "GStorage.h"
43 : : # include "Gmcrts.h"
44 : : #include <safe-ctype.h>
45 : : #if defined(__cplusplus)
46 : : # undef NULL
47 : : # define NULL 0
48 : : #endif
49 : : #define _M2MetaError_C
50 : :
51 : : #include "GM2MetaError.h"
52 : : # include "GM2Base.h"
53 : : # include "GNameKey.h"
54 : : # include "GStrLib.h"
55 : : # include "GM2LexBuf.h"
56 : : # include "GM2Error.h"
57 : : # include "GFIO.h"
58 : : # include "GSFIO.h"
59 : : # include "GStringConvert.h"
60 : : # include "GM2Printf.h"
61 : : # include "GM2Options.h"
62 : : # include "GStrCase.h"
63 : : # include "Glibc.h"
64 : : # include "GSYSTEM.h"
65 : : # include "GM2Debug.h"
66 : : # include "GStorage.h"
67 : : # include "GIndexing.h"
68 : : # include "GDynamicStrings.h"
69 : : # include "GSymbolTable.h"
70 : : # include "GM2ColorString.h"
71 : : # include "GM2RTS.h"
72 : :
73 : : # define MaxStack 10
74 : : # define Debugging false
75 : : # define ColorDebug false
76 : : typedef struct M2MetaError_GetTokProcedure_p M2MetaError_GetTokProcedure;
77 : :
78 : : typedef struct M2MetaError_errorBlock_r M2MetaError_errorBlock;
79 : :
80 : : typedef struct M2MetaError__T1_a M2MetaError__T1;
81 : :
82 : : typedef struct M2MetaError__T2_r M2MetaError__T2;
83 : :
84 : : typedef M2MetaError__T2 *M2MetaError_dictionaryEntry;
85 : :
86 : : typedef enum {M2MetaError_none, M2MetaError_error, M2MetaError_warning, M2MetaError_note, M2MetaError_chained, M2MetaError_aborta} M2MetaError_errorType;
87 : :
88 : : typedef enum {M2MetaError_unsetColor, M2MetaError_noColor, M2MetaError_quoteColor, M2MetaError_filenameColor, M2MetaError_errorColor, M2MetaError_warningColor, M2MetaError_noteColor, M2MetaError_keywordColor, M2MetaError_locusColor, M2MetaError_insertColor, M2MetaError_deleteColor, M2MetaError_typeColor, M2MetaError_range1Color, M2MetaError_range2Color} M2MetaError_colorType;
89 : :
90 : : typedef unsigned int (*M2MetaError_GetTokProcedure_t) (unsigned int);
91 : : struct M2MetaError_GetTokProcedure_p { M2MetaError_GetTokProcedure_t proc; };
92 : :
93 : : struct M2MetaError__T1_a { M2MetaError_colorType array[MaxStack+1]; };
94 : : struct M2MetaError__T2_r {
95 : : DynamicStrings_String key;
96 : : DynamicStrings_String value;
97 : : M2MetaError_dictionaryEntry next;
98 : : };
99 : :
100 : : struct M2MetaError_errorBlock_r {
101 : : bool useError;
102 : : M2Error_Error e;
103 : : M2MetaError_errorType type;
104 : : DynamicStrings_String out;
105 : : DynamicStrings_String in;
106 : : unsigned int highplus1;
107 : : int len;
108 : : int ini;
109 : : bool glyph;
110 : : bool chain;
111 : : bool root;
112 : : bool quotes;
113 : : bool positive;
114 : : M2MetaError_colorType currentCol;
115 : : M2MetaError_colorType beginCol;
116 : : M2MetaError_colorType endCol;
117 : : M2MetaError__T1 colorStack;
118 : : unsigned int stackPtr;
119 : : };
120 : :
121 : : static M2Error_Error lastRoot;
122 : : static M2MetaError_colorType lastColor;
123 : : static bool seenAbort;
124 : : static Indexing_Index dictionary;
125 : : static Indexing_Index outputStack;
126 : : static M2MetaError_dictionaryEntry freeEntry;
127 : : extern "C" void M2MetaError_MetaError0 (const char *m_, unsigned int _m_high);
128 : : extern "C" void M2MetaError_MetaError1 (const char *m_, unsigned int _m_high, unsigned int s);
129 : : extern "C" void M2MetaError_MetaError2 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2);
130 : : extern "C" void M2MetaError_MetaError3 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3);
131 : : extern "C" void M2MetaError_MetaError4 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
132 : :
133 : : /*
134 : : wrapErrors -
135 : : */
136 : :
137 : : extern "C" void M2MetaError_MetaErrors1 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s);
138 : :
139 : : /*
140 : : wrapErrors -
141 : : */
142 : :
143 : : extern "C" void M2MetaError_MetaErrors2 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2);
144 : :
145 : : /*
146 : : wrapErrors -
147 : : */
148 : :
149 : : extern "C" void M2MetaError_MetaErrors3 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3);
150 : :
151 : : /*
152 : : wrapErrors -
153 : : */
154 : :
155 : : extern "C" void M2MetaError_MetaErrors4 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
156 : : extern "C" void M2MetaError_MetaErrorT0 (unsigned int tok, const char *m_, unsigned int _m_high);
157 : : extern "C" void M2MetaError_MetaErrorT1 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s);
158 : : extern "C" void M2MetaError_MetaErrorT2 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2);
159 : : extern "C" void M2MetaError_MetaErrorT3 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3);
160 : : extern "C" void M2MetaError_MetaErrorT4 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
161 : :
162 : : /*
163 : : wrapErrors -
164 : : */
165 : :
166 : : extern "C" void M2MetaError_MetaErrorsT1 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s);
167 : :
168 : : /*
169 : : wrapErrors -
170 : : */
171 : :
172 : : extern "C" void M2MetaError_MetaErrorsT2 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2);
173 : :
174 : : /*
175 : : wrapErrors -
176 : : */
177 : :
178 : : extern "C" void M2MetaError_MetaErrorsT3 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3);
179 : :
180 : : /*
181 : : wrapErrors -
182 : : */
183 : :
184 : : extern "C" void M2MetaError_MetaErrorsT4 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
185 : :
186 : : /*
187 : : wrapErrors -
188 : : */
189 : :
190 : : extern "C" void M2MetaError_MetaErrorString0 (DynamicStrings_String m);
191 : :
192 : : /*
193 : : wrapErrors -
194 : : */
195 : :
196 : : extern "C" void M2MetaError_MetaErrorString1 (DynamicStrings_String m, unsigned int s);
197 : :
198 : : /*
199 : : wrapErrors -
200 : : */
201 : :
202 : : extern "C" void M2MetaError_MetaErrorString2 (DynamicStrings_String m, unsigned int s1, unsigned int s2);
203 : :
204 : : /*
205 : : wrapErrors -
206 : : */
207 : :
208 : : extern "C" void M2MetaError_MetaErrorString3 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3);
209 : :
210 : : /*
211 : : wrapErrors -
212 : : */
213 : :
214 : : extern "C" void M2MetaError_MetaErrorString4 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
215 : : extern "C" void M2MetaError_MetaErrorStringT0 (unsigned int tok, DynamicStrings_String m);
216 : : extern "C" void M2MetaError_MetaErrorStringT1 (unsigned int tok, DynamicStrings_String m, unsigned int s);
217 : : extern "C" void M2MetaError_MetaErrorStringT2 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2);
218 : : extern "C" void M2MetaError_MetaErrorStringT3 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3);
219 : : extern "C" void M2MetaError_MetaErrorStringT4 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
220 : :
221 : : /*
222 : : MetaErrorN1 -
223 : : */
224 : :
225 : : extern "C" void M2MetaError_MetaErrorN1 (const char *m_, unsigned int _m_high, NameKey_Name n);
226 : :
227 : : /*
228 : : MetaErrorN2 -
229 : : */
230 : :
231 : : extern "C" void M2MetaError_MetaErrorN2 (const char *m_, unsigned int _m_high, NameKey_Name n1, NameKey_Name n2);
232 : :
233 : : /*
234 : : MetaErrorNT0 - generate an error message at tok using format.
235 : : */
236 : :
237 : : extern "C" void M2MetaError_MetaErrorNT0 (unsigned int tok, const char *format_, unsigned int _format_high);
238 : :
239 : : /*
240 : : MetaErrorNT1 - generate an error message at tok using format and name.
241 : : The format should contain %a for name substitution.
242 : : */
243 : :
244 : : extern "C" void M2MetaError_MetaErrorNT1 (unsigned int tok, const char *format_, unsigned int _format_high, NameKey_Name name);
245 : : extern "C" void M2MetaError_MetaErrorNT2 (unsigned int tok, const char *format_, unsigned int _format_high, NameKey_Name name1, NameKey_Name name2);
246 : :
247 : : /*
248 : : wrapString - return a string which has been formatted with the specifier codes.
249 : : Color is disabled. The result string is returned.
250 : : */
251 : :
252 : : extern "C" DynamicStrings_String M2MetaError_MetaString0 (DynamicStrings_String m);
253 : :
254 : : /*
255 : : wrapString - return a string which has been formatted with the specifier codes.
256 : : Color is disabled. The result string is returned.
257 : : */
258 : :
259 : : extern "C" DynamicStrings_String M2MetaError_MetaString1 (DynamicStrings_String m, unsigned int s);
260 : :
261 : : /*
262 : : wrapString - return a string which has been formatted with the specifier codes.
263 : : Color is disabled. The result string is returned.
264 : : */
265 : :
266 : : extern "C" DynamicStrings_String M2MetaError_MetaString2 (DynamicStrings_String m, unsigned int s1, unsigned int s2);
267 : :
268 : : /*
269 : : wrapString - return a string which has been formatted with the specifier codes.
270 : : Color is disabled. The result string is returned.
271 : : */
272 : :
273 : : extern "C" DynamicStrings_String M2MetaError_MetaString3 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3);
274 : :
275 : : /*
276 : : wrapString - return a string which has been formatted with the specifier codes.
277 : : Color is disabled. The result string is returned.
278 : : */
279 : :
280 : : extern "C" DynamicStrings_String M2MetaError_MetaString4 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
281 : :
282 : : /*
283 : : MetaErrorDecl - if sym is a variable or parameter then generate a
284 : : declaration error or warning message. If error is
285 : : FALSE then a warning is issued.
286 : : */
287 : :
288 : : extern "C" void M2MetaError_MetaErrorDecl (unsigned int sym, bool error);
289 : :
290 : : /*
291 : : pushOutput -
292 : : */
293 : :
294 : : static void pushOutput (M2MetaError_errorBlock *eb);
295 : :
296 : : /*
297 : : readWord - reads and returns a word delimited by '}' it uses '%' as
298 : : the escape character.
299 : : */
300 : :
301 : : static DynamicStrings_String readWord (M2MetaError_errorBlock *eb);
302 : :
303 : : /*
304 : : addEntry -
305 : : */
306 : :
307 : : static void addEntry (DynamicStrings_String key, DynamicStrings_String value);
308 : :
309 : : /*
310 : : popOutput -
311 : : */
312 : :
313 : : static void popOutput (M2MetaError_errorBlock *eb);
314 : :
315 : : /*
316 : : newEntry -
317 : : */
318 : :
319 : : static M2MetaError_dictionaryEntry newEntry (void);
320 : :
321 : : /*
322 : : killEntry - dispose e and delete any strings.
323 : : */
324 : :
325 : : static void killEntry (M2MetaError_dictionaryEntry e);
326 : :
327 : : /*
328 : : resetDictionary - remove all entries in the dictionary.
329 : : */
330 : :
331 : : static void resetDictionary (void);
332 : :
333 : : /*
334 : : lookupString - lookup and return a duplicate of the string value for key s.
335 : : NIL is returned if the key s is unknown.
336 : : */
337 : :
338 : : static DynamicStrings_String lookupString (DynamicStrings_String s);
339 : :
340 : : /*
341 : : lookupDefine - looks up the word in the input string (ending with '}').
342 : : It uses this word as a key into the dictionary and returns
343 : : the entry.
344 : : */
345 : :
346 : : static DynamicStrings_String lookupDefine (M2MetaError_errorBlock *eb);
347 : :
348 : : /*
349 : : processDefine - place contents of dictionary entry name onto the output string.
350 : : */
351 : :
352 : : static void processDefine (M2MetaError_errorBlock *eb);
353 : :
354 : : /*
355 : : lookupColor - looks up the color enum from the string.
356 : : */
357 : :
358 : : static M2MetaError_colorType lookupColor (DynamicStrings_String s);
359 : :
360 : : /*
361 : : readColor -
362 : : */
363 : :
364 : : static M2MetaError_colorType readColor (M2MetaError_errorBlock *eb);
365 : :
366 : : /*
367 : : keyword - copy characters until the '}' in the input string and convert them to
368 : : the keyword color/font.
369 : : */
370 : :
371 : : static void keyword (M2MetaError_errorBlock *eb);
372 : :
373 : : /*
374 : : filename - copy characters until the '}' in the input string and convert them to
375 : : the filename color/font.
376 : : */
377 : :
378 : : static void filename (M2MetaError_errorBlock *eb);
379 : :
380 : : /*
381 : : pushColor -
382 : : */
383 : :
384 : : static void pushColor (M2MetaError_errorBlock *eb);
385 : :
386 : : /*
387 : : popColor -
388 : : */
389 : :
390 : : static void popColor (M2MetaError_errorBlock *eb);
391 : :
392 : : /*
393 : : initErrorBlock - initialise an error block with the, input, string.
394 : : */
395 : :
396 : : static void initErrorBlock (M2MetaError_errorBlock *eb, DynamicStrings_String input, const unsigned int *sym_, unsigned int _sym_high);
397 : :
398 : : /*
399 : : push - performs a push from the oldblock to the newblock.
400 : : It copies all fields except the output string.
401 : : */
402 : :
403 : : static void push (M2MetaError_errorBlock *newblock, M2MetaError_errorBlock oldblock);
404 : :
405 : : /*
406 : : pop - copies contents of oldblock into newblock. It only copies the error
407 : : handle if the toblock.e is NIL.
408 : : */
409 : :
410 : : static void pop (M2MetaError_errorBlock *toblock, M2MetaError_errorBlock *fromblock);
411 : :
412 : : /*
413 : : OutOpenQuote -
414 : : */
415 : :
416 : : static void OutOpenQuote (M2MetaError_errorBlock *eb);
417 : :
418 : : /*
419 : : OutCloseQuote -
420 : : */
421 : :
422 : : static void OutCloseQuote (M2MetaError_errorBlock *eb);
423 : :
424 : : /*
425 : : findColorType - return the color of the string. This is determined by the first
426 : : occurrance of an error, warning or note marker. An error message
427 : : is assumed to either be: a keyword category, error category, note
428 : : category, warning category or to be chained from a previous error.
429 : : */
430 : :
431 : : static M2MetaError_colorType findColorType (DynamicStrings_String s);
432 : :
433 : : /*
434 : : killErrorBlock - deallocates the dynamic strings associated with the error block.
435 : : */
436 : :
437 : : static void killErrorBlock (M2MetaError_errorBlock *eb);
438 : :
439 : : /*
440 : : InternalFormat - produces an informative internal error.
441 : : */
442 : :
443 : : static void InternalFormat (M2MetaError_errorBlock eb, const char *m_, unsigned int _m_high, unsigned int line);
444 : :
445 : : /*
446 : : x - checks to see that a=b.
447 : : */
448 : :
449 : : static DynamicStrings_String x (DynamicStrings_String a, DynamicStrings_String b);
450 : :
451 : : /*
452 : : IsWhite - returns TRUE if, ch, is a space.
453 : : */
454 : :
455 : : static bool IsWhite (char ch);
456 : :
457 : : /*
458 : : skip - skips over this level input until the next '}'.
459 : : */
460 : :
461 : : static void skip (M2MetaError_errorBlock *sb);
462 : :
463 : : /*
464 : : ifNonNulThen := [ ':' ebnf ] =:
465 : : */
466 : :
467 : : static void ifNonNulThen (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high);
468 : :
469 : : /*
470 : : doNumber -
471 : : */
472 : :
473 : : static void doNumber (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
474 : :
475 : : /*
476 : : doCount -
477 : : */
478 : :
479 : : static void doCount (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
480 : :
481 : : /*
482 : : doCount -
483 : : */
484 : :
485 : : static void doAscii (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
486 : :
487 : : /*
488 : : unquotedKeyword -
489 : : */
490 : :
491 : : static void unquotedKeyword (M2MetaError_errorBlock *eb);
492 : :
493 : : /*
494 : : OutArray -
495 : : */
496 : :
497 : : static void OutArray (M2MetaError_errorBlock *eb, const char *a_, unsigned int _a_high);
498 : :
499 : : /*
500 : : OutGlyphS - outputs a string of glyphs.
501 : : */
502 : :
503 : : static void OutGlyphS (M2MetaError_errorBlock *eb, DynamicStrings_String s);
504 : :
505 : : /*
506 : : empty - returns TRUE if the output string is empty.
507 : : It ignores color changes.
508 : : */
509 : :
510 : : static bool empty (M2MetaError_errorBlock *eb);
511 : :
512 : : /*
513 : : clear - remove the output string.
514 : : */
515 : :
516 : : static void clear (M2MetaError_errorBlock *eb);
517 : :
518 : : /*
519 : : clear - remove the output string.
520 : : */
521 : :
522 : : static void doName (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
523 : :
524 : : /*
525 : : clear - remove the output string.
526 : : */
527 : :
528 : : static void doQualified (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
529 : :
530 : : /*
531 : : doType - returns a string containing the type name of
532 : : sym.
533 : : */
534 : :
535 : : static void doType (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
536 : :
537 : : /*
538 : : doSkipType - will skip all pseudonym types. It also
539 : : returns the type symbol found and name.
540 : : */
541 : :
542 : : static void doSkipType (M2MetaError_errorBlock eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
543 : :
544 : : /*
545 : : doGetType - attempts to get the type of sym[bol].
546 : : */
547 : :
548 : : static void doGetType (M2MetaError_errorBlock *eb, unsigned int *sym, unsigned int _sym_high, unsigned int bol);
549 : :
550 : : /*
551 : : doGetSkipType - will skip all pseudonym types. It also
552 : : returns the type symbol found and name.
553 : : */
554 : :
555 : : static void doGetSkipType (M2MetaError_errorBlock *eb, unsigned int *sym, unsigned int _sym_high, unsigned int bol);
556 : :
557 : : /*
558 : : doChain -
559 : : */
560 : :
561 : : static void doChain (M2MetaError_errorBlock *eb, unsigned int tok);
562 : :
563 : : /*
564 : : doError - creates and returns an error note.
565 : : */
566 : :
567 : : static void doError (M2MetaError_errorBlock *eb, unsigned int tok);
568 : :
569 : : /*
570 : : defaultError - adds the default error location to, tok, if one has not already been
571 : : assigned.
572 : : */
573 : :
574 : : static void defaultError (M2MetaError_errorBlock *eb, unsigned int tok);
575 : :
576 : : /*
577 : : chooseError - choose the error kind dependant upon type.
578 : : Either an error, warning or note will be generated.
579 : : */
580 : :
581 : : static void chooseError (M2MetaError_errorBlock *eb, unsigned int tok);
582 : :
583 : : /*
584 : : doErrorScopeModule -
585 : : */
586 : :
587 : : static void doErrorScopeModule (M2MetaError_errorBlock *eb, unsigned int sym);
588 : :
589 : : /*
590 : : doErrorScopeForward -
591 : : */
592 : :
593 : : static void doErrorScopeForward (M2MetaError_errorBlock *eb, unsigned int sym);
594 : :
595 : : /*
596 : : doErrorScopeMod - potentially create an error referring to the definition
597 : : module, fall back to the implementation or program module if
598 : : there is no declaration in the definition module.
599 : : */
600 : :
601 : : static void doErrorScopeMod (M2MetaError_errorBlock *eb, unsigned int sym);
602 : :
603 : : /*
604 : : doErrorScopeFor - potentially create an error referring to the
605 : : forward declaration, definition module, fall back
606 : : to the implementation or program module if
607 : : there is no declaration in the definition module.
608 : : */
609 : :
610 : : static void doErrorScopeFor (M2MetaError_errorBlock *eb, unsigned int sym);
611 : : static void declaredMod (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
612 : :
613 : : /*
614 : : doErrorScopeDefinition - use the declaration in the definitio module if one is available.
615 : : */
616 : :
617 : : static void doErrorScopeDefinition (M2MetaError_errorBlock *eb, unsigned int sym);
618 : :
619 : : /*
620 : : doErrorScopeDef - potentially create an error referring to the definition
621 : : module, fall back to the implementation or program module if
622 : : there is no declaration in the definition module.
623 : : */
624 : :
625 : : static void doErrorScopeDef (M2MetaError_errorBlock *eb, unsigned int sym);
626 : : static void declaredDef (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
627 : : static void declaredFor (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
628 : :
629 : : /*
630 : : doErrorScopeProc - determine the location for the error or warning from
631 : : the default declaration. For example parameters can be
632 : : declared in definition, forward or in modules (proper procedure).
633 : : Use GetVarParamTok to obtain a variable or parameter location.
634 : : */
635 : :
636 : : static void doErrorScopeProc (M2MetaError_errorBlock *eb, unsigned int sym, M2MetaError_GetTokProcedure GetVarParamTok);
637 : : static void declaredVar (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
638 : : static void declaredType (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
639 : : static void declaredFull (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
640 : :
641 : : /*
642 : : used - creates an error note where sym[bol] was first used.
643 : : */
644 : :
645 : : static void used (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
646 : :
647 : : /*
648 : : symDesc -
649 : : */
650 : :
651 : : static DynamicStrings_String symDesc (unsigned int sym);
652 : :
653 : : /*
654 : : doDesc -
655 : : */
656 : :
657 : : static void doDesc (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
658 : :
659 : : /*
660 : : op := {'!'|'a'|'c'|'d'|'k'|'n'|'p'|'q'|'s'|'t'|'u'|
661 : : 'A'|'B'|'C'|'D'|'E'|'F'|'G'|'H'|'K'|'M'|'N'|
662 : : 'O'|'P'|'Q'|'R'|'S'|'T'|'U'|'V'|'W'|'X'|'Y'|'Z'} then =:
663 : : */
664 : :
665 : : static void op (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol);
666 : :
667 : : /*
668 : : percenttoken := '%' (
669 : : '1' % doOperand(1) %
670 : : op
671 : : | '2' % doOperand(2) %
672 : : op
673 : : | '3' % doOperand(3) %
674 : : op
675 : : | '4' % doOperand(4) %
676 : : op
677 : : )
678 : : } =:
679 : : */
680 : :
681 : : static void percenttoken (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high);
682 : :
683 : : /*
684 : : changeColor - changes to color, c.
685 : : */
686 : :
687 : : static void changeColor (M2MetaError_errorBlock *eb, M2MetaError_colorType c);
688 : :
689 : : /*
690 : : shutdownColor - shutdown existing color if it exists.
691 : : */
692 : :
693 : : static void shutdownColor (M2MetaError_errorBlock *eb);
694 : :
695 : : /*
696 : : flushColor - flushes any outstanding color change.
697 : : */
698 : :
699 : : static void flushColor (M2MetaError_errorBlock *eb);
700 : :
701 : : /*
702 : : emitColorGCC -
703 : : */
704 : :
705 : : static void emitColorGCC (M2MetaError_errorBlock *eb, M2MetaError_colorType c);
706 : :
707 : : /*
708 : : emitColorTag -
709 : : */
710 : :
711 : : static void emitColorTag (M2MetaError_errorBlock *eb, M2MetaError_colorType c);
712 : :
713 : : /*
714 : : emitColor - adds the appropriate color string to the output string.
715 : : */
716 : :
717 : : static void emitColor (M2MetaError_errorBlock *eb, M2MetaError_colorType c);
718 : :
719 : : /*
720 : : openQuote -
721 : : */
722 : :
723 : : static DynamicStrings_String openQuote (DynamicStrings_String s);
724 : :
725 : : /*
726 : : closeQuote -
727 : : */
728 : :
729 : : static DynamicStrings_String closeQuote (DynamicStrings_String s);
730 : :
731 : : /*
732 : : colorEnd -
733 : : */
734 : :
735 : : static DynamicStrings_String colorEnd (DynamicStrings_String s);
736 : :
737 : : /*
738 : : copyChar - copies a character from in string to out string.
739 : : */
740 : :
741 : : static void copyChar (M2MetaError_errorBlock *eb);
742 : :
743 : : /*
744 : : copyKeywordChar - copies a character from in string to out string
745 : : it will convert the character to lower case if the
746 : : -fm2-lower-case option was specified.
747 : : */
748 : :
749 : : static void copyKeywordChar (M2MetaError_errorBlock *eb);
750 : :
751 : : /*
752 : : percent := '%' anych % copy anych %
753 : : =:
754 : : */
755 : :
756 : : static void percent (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high);
757 : :
758 : : /*
759 : : lbra := '{' [ '!' ] percenttoken '}' =:
760 : : */
761 : :
762 : : static void lbra (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high);
763 : :
764 : : /*
765 : : lbra := '{' [ '!' ] percenttoken '}' =:
766 : : */
767 : :
768 : : static void stop (void);
769 : :
770 : : /*
771 : : lbra := '{' [ '!' ] percenttoken '}' =:
772 : : */
773 : :
774 : : static void checkMe (void);
775 : :
776 : : /*
777 : : dumpErrorType -
778 : : */
779 : :
780 : : static void dumpErrorType (M2MetaError_errorType e);
781 : :
782 : : /*
783 : : dumpColorType -
784 : : */
785 : :
786 : : static void dumpColorType (M2MetaError_colorType c);
787 : :
788 : : /*
789 : : dump -
790 : :
791 : : */
792 : :
793 : : static void dump (M2MetaError_errorBlock eb);
794 : :
795 : : /*
796 : : ebnf := { percent
797 : : | lbra
798 : : | any % copy ch %
799 : : }
800 : : =:
801 : : */
802 : :
803 : : static void ebnf (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high);
804 : :
805 : : /*
806 : : wrapErrors -
807 : : */
808 : :
809 : : static void wrapErrors (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned int *sym_, unsigned int _sym_high);
810 : :
811 : : /*
812 : : checkAbort - checks to see if the boolean flag seenAbort has been set,
813 : : if so it flushes all existing errors and terminates.
814 : : */
815 : :
816 : : static void checkAbort (void);
817 : :
818 : : /*
819 : : translate -
820 : : */
821 : :
822 : : static DynamicStrings_String translate (DynamicStrings_String m, DynamicStrings_String s, int *i, NameKey_Name name);
823 : :
824 : : /*
825 : : wrapString - return a string which has been formatted with the specifier codes.
826 : : Color is disabled. The result string is returned.
827 : : */
828 : :
829 : : static DynamicStrings_String wrapString (DynamicStrings_String m, const unsigned int *sym_, unsigned int _sym_high);
830 : :
831 : :
832 : : /*
833 : : pushOutput -
834 : : */
835 : :
836 : 0 : static void pushOutput (M2MetaError_errorBlock *eb)
837 : : {
838 : 0 : Indexing_PutIndice (outputStack, (Indexing_HighIndice (outputStack))+1, reinterpret_cast <void *> ((*eb).out));
839 : 0 : (*eb).out = DynamicStrings_InitString ((const char *) "", 0);
840 : 0 : (*eb).glyph = false;
841 : 0 : }
842 : :
843 : :
844 : : /*
845 : : readWord - reads and returns a word delimited by '}' it uses '%' as
846 : : the escape character.
847 : : */
848 : :
849 : 0 : static DynamicStrings_String readWord (M2MetaError_errorBlock *eb)
850 : : {
851 : 0 : DynamicStrings_String word;
852 : :
853 : 0 : word = DynamicStrings_InitString ((const char *) "", 0);
854 : 0 : while (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
855 : : {
856 : 0 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '%')
857 : : {
858 : 0 : (*eb).ini += 1;
859 : : }
860 : 0 : word = DynamicStrings_ConCatChar (word, DynamicStrings_char ((*eb).in, (*eb).ini));
861 : 0 : (*eb).ini += 1;
862 : : }
863 : 0 : return word;
864 : : /* static analysis guarentees a RETURN statement will be used before here. */
865 : : __builtin_unreachable ();
866 : : }
867 : :
868 : :
869 : : /*
870 : : addEntry -
871 : : */
872 : :
873 : 0 : static void addEntry (DynamicStrings_String key, DynamicStrings_String value)
874 : : {
875 : 0 : M2MetaError_dictionaryEntry e;
876 : 0 : DynamicStrings_String s;
877 : 0 : unsigned int i;
878 : :
879 : 0 : s = lookupString (key);
880 : 0 : if (s == NULL)
881 : : {
882 : 0 : e = newEntry ();
883 : 0 : e->key = key;
884 : 0 : e->value = value;
885 : 0 : Indexing_PutIndice (dictionary, (Indexing_HighIndice (dictionary))+1, reinterpret_cast <void *> (e));
886 : : }
887 : : else
888 : : {
889 : : i = 1;
890 : 0 : while (i <= (Indexing_HighIndice (dictionary)))
891 : : {
892 : 0 : e = static_cast<M2MetaError_dictionaryEntry> (Indexing_GetIndice (dictionary, i));
893 : 0 : if (DynamicStrings_Equal (e->key, key))
894 : : {
895 : 0 : e->value = DynamicStrings_KillString (e->value);
896 : 0 : e->value = value;
897 : 0 : return;
898 : : }
899 : 0 : i += 1;
900 : : }
901 : : }
902 : : }
903 : :
904 : :
905 : : /*
906 : : popOutput -
907 : : */
908 : :
909 : 0 : static void popOutput (M2MetaError_errorBlock *eb)
910 : : {
911 : 0 : DynamicStrings_String key;
912 : 0 : DynamicStrings_String previous;
913 : :
914 : 0 : if ((Indexing_HighIndice (outputStack)) >= 1)
915 : : {
916 : 0 : previous = static_cast<DynamicStrings_String> (Indexing_GetIndice (outputStack, Indexing_HighIndice (outputStack)));
917 : 0 : Indexing_DeleteIndice (outputStack, Indexing_HighIndice (outputStack));
918 : 0 : key = readWord (eb);
919 : 0 : addEntry (key, (*eb).out);
920 : 0 : (*eb).out = previous;
921 : : }
922 : 0 : }
923 : :
924 : :
925 : : /*
926 : : newEntry -
927 : : */
928 : :
929 : 0 : static M2MetaError_dictionaryEntry newEntry (void)
930 : : {
931 : 0 : M2MetaError_dictionaryEntry e;
932 : :
933 : 0 : if (freeEntry == NULL)
934 : : {
935 : 0 : Storage_ALLOCATE ((void **) &e, sizeof (M2MetaError__T2));
936 : : }
937 : : else
938 : : {
939 : 0 : e = freeEntry;
940 : 0 : freeEntry = freeEntry->next;
941 : : }
942 : 0 : e->key = static_cast<DynamicStrings_String> (NULL);
943 : 0 : e->value = static_cast<DynamicStrings_String> (NULL);
944 : 0 : e->next = NULL;
945 : 0 : return e;
946 : : /* static analysis guarentees a RETURN statement will be used before here. */
947 : : __builtin_unreachable ();
948 : : }
949 : :
950 : :
951 : : /*
952 : : killEntry - dispose e and delete any strings.
953 : : */
954 : :
955 : 0 : static void killEntry (M2MetaError_dictionaryEntry e)
956 : : {
957 : 0 : e->next = freeEntry;
958 : 0 : freeEntry = e;
959 : 0 : if (e->key != NULL)
960 : : {
961 : 0 : e->key = DynamicStrings_KillString (e->key);
962 : : }
963 : 0 : if (e->value != NULL)
964 : : {
965 : 0 : e->value = DynamicStrings_KillString (e->value);
966 : : }
967 : 0 : }
968 : :
969 : :
970 : : /*
971 : : resetDictionary - remove all entries in the dictionary.
972 : : */
973 : :
974 : 0 : static void resetDictionary (void)
975 : : {
976 : 0 : unsigned int i;
977 : 0 : M2MetaError_dictionaryEntry e;
978 : :
979 : 0 : i = 1;
980 : 0 : while (i <= (Indexing_HighIndice (dictionary)))
981 : : {
982 : 0 : e = static_cast<M2MetaError_dictionaryEntry> (Indexing_GetIndice (dictionary, i));
983 : 0 : killEntry (e);
984 : 0 : i += 1;
985 : : }
986 : 0 : dictionary = Indexing_KillIndex (dictionary);
987 : 0 : dictionary = Indexing_InitIndex (1);
988 : 0 : }
989 : :
990 : :
991 : : /*
992 : : lookupString - lookup and return a duplicate of the string value for key s.
993 : : NIL is returned if the key s is unknown.
994 : : */
995 : :
996 : 0 : static DynamicStrings_String lookupString (DynamicStrings_String s)
997 : : {
998 : 0 : unsigned int i;
999 : 0 : M2MetaError_dictionaryEntry e;
1000 : :
1001 : 0 : i = 1;
1002 : 0 : while (i <= (Indexing_HighIndice (dictionary)))
1003 : : {
1004 : 0 : e = static_cast<M2MetaError_dictionaryEntry> (Indexing_GetIndice (dictionary, i));
1005 : 0 : if (DynamicStrings_Equal (e->key, s))
1006 : : {
1007 : 0 : return DynamicStrings_Dup (e->value);
1008 : : }
1009 : 0 : i += 1;
1010 : : }
1011 : : return static_cast<DynamicStrings_String> (NULL);
1012 : : /* static analysis guarentees a RETURN statement will be used before here. */
1013 : : __builtin_unreachable ();
1014 : : }
1015 : :
1016 : :
1017 : : /*
1018 : : lookupDefine - looks up the word in the input string (ending with '}').
1019 : : It uses this word as a key into the dictionary and returns
1020 : : the entry.
1021 : : */
1022 : :
1023 : 0 : static DynamicStrings_String lookupDefine (M2MetaError_errorBlock *eb)
1024 : : {
1025 : 0 : DynamicStrings_String s;
1026 : :
1027 : 0 : s = DynamicStrings_InitString ((const char *) "", 0);
1028 : 0 : while (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
1029 : : {
1030 : 0 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '%')
1031 : : {
1032 : 0 : (*eb).ini += 1;
1033 : : }
1034 : 0 : s = DynamicStrings_ConCatChar (s, DynamicStrings_char ((*eb).in, (*eb).ini));
1035 : 0 : (*eb).ini += 1;
1036 : : }
1037 : 0 : s = lookupString (s);
1038 : 0 : if (s == NULL)
1039 : : {
1040 : 0 : s = DynamicStrings_InitString ((const char *) "", 0);
1041 : : }
1042 : 0 : return s;
1043 : : /* static analysis guarentees a RETURN statement will be used before here. */
1044 : : __builtin_unreachable ();
1045 : : }
1046 : :
1047 : :
1048 : : /*
1049 : : processDefine - place contents of dictionary entry name onto the output string.
1050 : : */
1051 : :
1052 : 0 : static void processDefine (M2MetaError_errorBlock *eb)
1053 : : {
1054 : 0 : (*eb).out = DynamicStrings_ConCat ((*eb).out, lookupDefine (eb));
1055 : 0 : }
1056 : :
1057 : :
1058 : : /*
1059 : : lookupColor - looks up the color enum from the string.
1060 : : */
1061 : :
1062 : 0 : static M2MetaError_colorType lookupColor (DynamicStrings_String s)
1063 : : {
1064 : 0 : if (DynamicStrings_EqualArray (s, (const char *) "filename", 8))
1065 : : {
1066 : : return M2MetaError_filenameColor;
1067 : : }
1068 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "quote", 5))
1069 : : {
1070 : : /* avoid dangling else. */
1071 : : return M2MetaError_quoteColor;
1072 : : }
1073 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "error", 5))
1074 : : {
1075 : : /* avoid dangling else. */
1076 : : return M2MetaError_errorColor;
1077 : : }
1078 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "warning", 7))
1079 : : {
1080 : : /* avoid dangling else. */
1081 : : return M2MetaError_warningColor;
1082 : : }
1083 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "note", 4))
1084 : : {
1085 : : /* avoid dangling else. */
1086 : : return M2MetaError_warningColor;
1087 : : }
1088 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "locus", 5))
1089 : : {
1090 : : /* avoid dangling else. */
1091 : : return M2MetaError_locusColor;
1092 : : }
1093 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "insert", 6))
1094 : : {
1095 : : /* avoid dangling else. */
1096 : : return M2MetaError_insertColor;
1097 : : }
1098 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "delete", 6))
1099 : : {
1100 : : /* avoid dangling else. */
1101 : : return M2MetaError_deleteColor;
1102 : : }
1103 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "type", 4))
1104 : : {
1105 : : /* avoid dangling else. */
1106 : : return M2MetaError_typeColor;
1107 : : }
1108 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "range1", 6))
1109 : : {
1110 : : /* avoid dangling else. */
1111 : : return M2MetaError_range1Color;
1112 : : }
1113 : 0 : else if (DynamicStrings_EqualArray (s, (const char *) "range2", 6))
1114 : : {
1115 : : /* avoid dangling else. */
1116 : 0 : return M2MetaError_range2Color;
1117 : : }
1118 : : return M2MetaError_noColor;
1119 : : /* static analysis guarentees a RETURN statement will be used before here. */
1120 : : __builtin_unreachable ();
1121 : : }
1122 : :
1123 : :
1124 : : /*
1125 : : readColor -
1126 : : */
1127 : :
1128 : 0 : static M2MetaError_colorType readColor (M2MetaError_errorBlock *eb)
1129 : : {
1130 : 0 : DynamicStrings_String s;
1131 : 0 : M2MetaError_colorType c;
1132 : :
1133 : 0 : s = DynamicStrings_InitString ((const char *) "", 0);
1134 : 0 : while (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
1135 : : {
1136 : 0 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '%')
1137 : : {
1138 : 0 : (*eb).ini += 1;
1139 : : }
1140 : 0 : s = DynamicStrings_ConCatChar (s, DynamicStrings_char ((*eb).in, (*eb).ini));
1141 : 0 : (*eb).ini += 1;
1142 : : }
1143 : 0 : c = lookupColor (s);
1144 : 0 : s = DynamicStrings_KillString (s);
1145 : 0 : return c;
1146 : : /* static analysis guarentees a RETURN statement will be used before here. */
1147 : : __builtin_unreachable ();
1148 : : }
1149 : :
1150 : :
1151 : : /*
1152 : : keyword - copy characters until the '}' in the input string and convert them to
1153 : : the keyword color/font.
1154 : : */
1155 : :
1156 : 1152 : static void keyword (M2MetaError_errorBlock *eb)
1157 : : {
1158 : 1152 : if (TOUPPER (DynamicStrings_char ((*eb).in, (*eb).ini)) == 'K')
1159 : : {
1160 : 1152 : (*eb).ini += 1;
1161 : 1152 : pushColor (eb);
1162 : 1152 : changeColor (eb, M2MetaError_keywordColor);
1163 : 6150 : while (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
1164 : : {
1165 : 4998 : if (Debugging)
1166 : : {
1167 : : dump ((*eb));
1168 : : }
1169 : 4998 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '%')
1170 : : {
1171 : 12 : (*eb).ini += 1;
1172 : : }
1173 : 4998 : copyKeywordChar (eb);
1174 : 4998 : (*eb).ini += 1;
1175 : : }
1176 : 1152 : popColor (eb);
1177 : : }
1178 : : else
1179 : : {
1180 : 0 : M2Error_InternalError ((const char *) "expecting index to be on the K for keyword", 42);
1181 : : }
1182 : 1152 : }
1183 : :
1184 : :
1185 : : /*
1186 : : filename - copy characters until the '}' in the input string and convert them to
1187 : : the filename color/font.
1188 : : */
1189 : :
1190 : 0 : static void filename (M2MetaError_errorBlock *eb)
1191 : : {
1192 : 0 : if (TOUPPER (DynamicStrings_char ((*eb).in, (*eb).ini)) == 'F')
1193 : : {
1194 : 0 : (*eb).ini += 1;
1195 : 0 : pushColor (eb);
1196 : 0 : changeColor (eb, M2MetaError_filenameColor);
1197 : 0 : while (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
1198 : : {
1199 : 0 : if (Debugging)
1200 : : {
1201 : : dump ((*eb));
1202 : : }
1203 : 0 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '%')
1204 : : {
1205 : 0 : (*eb).ini += 1;
1206 : : }
1207 : 0 : copyChar (eb);
1208 : 0 : (*eb).ini += 1;
1209 : : }
1210 : 0 : popColor (eb);
1211 : : }
1212 : : else
1213 : : {
1214 : 0 : M2Error_InternalError ((const char *) "expecting index to be on the F for filename", 43);
1215 : : }
1216 : 0 : }
1217 : :
1218 : :
1219 : : /*
1220 : : pushColor -
1221 : : */
1222 : :
1223 : 51022 : static void pushColor (M2MetaError_errorBlock *eb)
1224 : : {
1225 : 51022 : if ((*eb).stackPtr > MaxStack)
1226 : : {
1227 : 0 : M2RTS_HALT (-1);
1228 : : __builtin_unreachable ();
1229 : : }
1230 : : else
1231 : : {
1232 : 51022 : (*eb).colorStack.array[(*eb).stackPtr] = (*eb).currentCol;
1233 : 51022 : (*eb).stackPtr += 1;
1234 : : }
1235 : 51022 : }
1236 : :
1237 : :
1238 : : /*
1239 : : popColor -
1240 : : */
1241 : :
1242 : 13180 : static void popColor (M2MetaError_errorBlock *eb)
1243 : : {
1244 : 13180 : if ((*eb).stackPtr > 0)
1245 : : {
1246 : 13180 : (*eb).stackPtr -= 1;
1247 : : }
1248 : : else
1249 : : {
1250 : 0 : M2RTS_HALT (-1);
1251 : : __builtin_unreachable ();
1252 : : }
1253 : 13180 : (*eb).currentCol = (*eb).colorStack.array[(*eb).stackPtr];
1254 : 13180 : if ((*eb).currentCol == M2MetaError_unsetColor)
1255 : : {
1256 : 0 : (*eb).currentCol = M2MetaError_noColor;
1257 : : }
1258 : 13180 : }
1259 : :
1260 : :
1261 : : /*
1262 : : initErrorBlock - initialise an error block with the, input, string.
1263 : : */
1264 : :
1265 : 16067 : static void initErrorBlock (M2MetaError_errorBlock *eb, DynamicStrings_String input, const unsigned int *sym_, unsigned int _sym_high)
1266 : : {
1267 : 16067 : unsigned int sym[_sym_high+1];
1268 : :
1269 : : /* make a local copy of each unbounded array. */
1270 : 16067 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1271 : :
1272 : 16067 : (*eb).useError = true;
1273 : 16067 : (*eb).e = static_cast<M2Error_Error> (NULL);
1274 : 16067 : (*eb).type = M2MetaError_error; /* default to the error color. */
1275 : 32134 : (*eb).out = DynamicStrings_InitString ((const char *) "", 0); /* default to the error color. */
1276 : 16067 : (*eb).in = input;
1277 : 16067 : (*eb).highplus1 = _sym_high+1;
1278 : 16067 : (*eb).len = DynamicStrings_Length (input);
1279 : 16067 : (*eb).ini = 0;
1280 : 16067 : (*eb).glyph = false; /* nothing to output yet. */
1281 : 16067 : (*eb).quotes = true; /* nothing to output yet. */
1282 : 16067 : (*eb).positive = true;
1283 : 16067 : (*eb).root = false;
1284 : 16067 : (*eb).chain = false;
1285 : 16067 : (*eb).currentCol = findColorType (input);
1286 : 16067 : (*eb).beginCol = M2MetaError_unsetColor;
1287 : 16067 : (*eb).endCol = M2MetaError_unsetColor;
1288 : 16067 : (*eb).stackPtr = 0;
1289 : 16067 : }
1290 : :
1291 : :
1292 : : /*
1293 : : push - performs a push from the oldblock to the newblock.
1294 : : It copies all fields except the output string.
1295 : : */
1296 : :
1297 : 40678 : static void push (M2MetaError_errorBlock *newblock, M2MetaError_errorBlock oldblock)
1298 : : {
1299 : 40678 : pushColor (&oldblock); /* save the current color. */
1300 : 40678 : (*newblock) = oldblock; /* copy all the fields. */
1301 : 40678 : (*newblock).out = static_cast<DynamicStrings_String> (NULL); /* must do this before a clear as we have copied the address. */
1302 : 40678 : clear (newblock); /* must do this before a clear as we have copied the address. */
1303 : 40678 : (*newblock).quotes = true;
1304 : 40678 : }
1305 : :
1306 : :
1307 : : /*
1308 : : pop - copies contents of oldblock into newblock. It only copies the error
1309 : : handle if the toblock.e is NIL.
1310 : : */
1311 : :
1312 : 40678 : static void pop (M2MetaError_errorBlock *toblock, M2MetaError_errorBlock *fromblock)
1313 : : {
1314 : 40678 : M2MetaError_colorType c;
1315 : :
1316 : 40678 : if (empty (fromblock))
1317 : : {
1318 : 2836 : (*toblock).stackPtr = (*fromblock).stackPtr;
1319 : 2836 : (*toblock).colorStack = (*fromblock).colorStack;
1320 : 2836 : popColor (toblock); /* and restore the color from the push start. */
1321 : : }
1322 : : else
1323 : : {
1324 : 37842 : if ((*fromblock).quotes)
1325 : : {
1326 : : /* string needs to be quoted. */
1327 : 28758 : if ((*toblock).currentCol == M2MetaError_unsetColor)
1328 : : {
1329 : : /* caller has not yet assigned a color, so use the callee color at the end. */
1330 : 0 : OutOpenQuote (toblock);
1331 : 0 : OutGlyphS (toblock, (*fromblock).out);
1332 : 0 : OutCloseQuote (toblock);
1333 : 0 : changeColor (toblock, (*fromblock).currentCol);
1334 : : }
1335 : : else
1336 : : {
1337 : 28758 : shutdownColor (fromblock);
1338 : : /* caller has assigned a color, so use it after the new string. */
1339 : 28758 : c = (*toblock).currentCol;
1340 : 28758 : OutOpenQuote (toblock);
1341 : 28758 : OutGlyphS (toblock, (*fromblock).out);
1342 : 28758 : OutCloseQuote (toblock);
1343 : 28758 : (*toblock).currentCol = c;
1344 : : }
1345 : : }
1346 : : else
1347 : : {
1348 : 9084 : if ((*toblock).currentCol == M2MetaError_unsetColor)
1349 : : {
1350 : 0 : OutGlyphS (toblock, (*fromblock).out);
1351 : 0 : (*toblock).endCol = (*fromblock).endCol;
1352 : 0 : changeColor (toblock, (*fromblock).endCol);
1353 : : }
1354 : : else
1355 : : {
1356 : 9084 : pushColor (toblock);
1357 : 9084 : OutGlyphS (toblock, (*fromblock).out);
1358 : 9084 : (*toblock).endCol = (*fromblock).endCol;
1359 : 9084 : popColor (toblock);
1360 : : }
1361 : : }
1362 : : }
1363 : 40678 : if ((*toblock).e == NULL)
1364 : : {
1365 : 40540 : (*toblock).e = (*fromblock).e;
1366 : : }
1367 : 40678 : (*toblock).chain = (*fromblock).chain;
1368 : 40678 : (*toblock).root = (*fromblock).root;
1369 : 40678 : (*toblock).ini = (*fromblock).ini;
1370 : 40678 : (*toblock).type = (*fromblock).type; /* might have been changed by the callee. */
1371 : 40678 : }
1372 : :
1373 : :
1374 : : /*
1375 : : OutOpenQuote -
1376 : : */
1377 : :
1378 : 28758 : static void OutOpenQuote (M2MetaError_errorBlock *eb)
1379 : : {
1380 : 28758 : (*eb).currentCol = M2MetaError_noColor;
1381 : 28758 : flushColor (eb);
1382 : 57516 : (*eb).out = DynamicStrings_ConCat ((*eb).out, openQuote (DynamicStrings_InitString ((const char *) "", 0)));
1383 : 28758 : }
1384 : :
1385 : :
1386 : : /*
1387 : : OutCloseQuote -
1388 : : */
1389 : :
1390 : 28758 : static void OutCloseQuote (M2MetaError_errorBlock *eb)
1391 : : {
1392 : 57516 : (*eb).out = DynamicStrings_ConCat ((*eb).out, closeQuote (DynamicStrings_InitString ((const char *) "", 0)));
1393 : 28758 : (*eb).currentCol = M2MetaError_noColor;
1394 : 28758 : (*eb).endCol = M2MetaError_noColor;
1395 : 28758 : }
1396 : :
1397 : :
1398 : : /*
1399 : : findColorType - return the color of the string. This is determined by the first
1400 : : occurrance of an error, warning or note marker. An error message
1401 : : is assumed to either be: a keyword category, error category, note
1402 : : category, warning category or to be chained from a previous error.
1403 : : */
1404 : :
1405 : 16109 : static M2MetaError_colorType findColorType (DynamicStrings_String s)
1406 : : {
1407 : 16109 : unsigned int i;
1408 : :
1409 : 16109 : i = 0;
1410 : 730553 : while (i < (DynamicStrings_Length (s)))
1411 : : {
1412 : 727185 : if ((DynamicStrings_char (s, static_cast<int> (i))) == '{')
1413 : : {
1414 : 19135 : i += 1;
1415 : 19135 : if ((DynamicStrings_char (s, static_cast<int> (i))) == '%')
1416 : : {
1417 : 19135 : i += 1;
1418 : 55856 : while ((i < (DynamicStrings_Length (s))) && ((DynamicStrings_char (s, static_cast<int> (i))) != '}'))
1419 : : {
1420 : 49462 : if ((DynamicStrings_char (s, static_cast<int> (i))) == '%')
1421 : : {
1422 : 66 : i += 1;
1423 : : }
1424 : 49462 : switch (DynamicStrings_char (s, static_cast<int> (i)))
1425 : : {
1426 : : case 'K':
1427 : : return M2MetaError_errorColor; /* keyword errors start with the fatal error color. */
1428 : : break;
1429 : :
1430 : : case 'E':
1431 : : return M2MetaError_errorColor; /* keyword errors start with the fatal error color. */
1432 : : break;
1433 : :
1434 : : case 'A':
1435 : : return M2MetaError_errorColor;
1436 : : break;
1437 : :
1438 : : case 'O':
1439 : : return M2MetaError_noteColor;
1440 : 10502 : break;
1441 : :
1442 : 10502 : case 'W':
1443 : 10502 : return M2MetaError_warningColor;
1444 : 186 : break;
1445 : :
1446 : 186 : case 'C':
1447 : 186 : return lastColor;
1448 : 36721 : break;
1449 : :
1450 : :
1451 : 36721 : default:
1452 : 36721 : break;
1453 : : }
1454 : 36721 : i += 1;
1455 : : }
1456 : : }
1457 : : }
1458 : 714444 : i += 1;
1459 : : }
1460 : : return M2MetaError_errorColor; /* default to the error color. */
1461 : : /* static analysis guarentees a RETURN statement will be used before here. */
1462 : : __builtin_unreachable ();
1463 : : }
1464 : :
1465 : :
1466 : : /*
1467 : : killErrorBlock - deallocates the dynamic strings associated with the error block.
1468 : : */
1469 : :
1470 : 16067 : static void killErrorBlock (M2MetaError_errorBlock *eb)
1471 : : {
1472 : 16067 : (*eb).out = DynamicStrings_KillString ((*eb).out);
1473 : 16067 : (*eb).in = DynamicStrings_KillString ((*eb).in);
1474 : 16067 : }
1475 : :
1476 : :
1477 : : /*
1478 : : InternalFormat - produces an informative internal error.
1479 : : */
1480 : :
1481 : 0 : static void InternalFormat (M2MetaError_errorBlock eb, const char *m_, unsigned int _m_high, unsigned int line)
1482 : : {
1483 : 0 : char m[_m_high+1];
1484 : :
1485 : : /* make a local copy of each unbounded array. */
1486 : 0 : memcpy (m, m_, _m_high+1);
1487 : :
1488 : 0 : M2Printf_printf1 ((const char *) "M2MetaError.mod:%d:internalformat error detected\\n", 50, (const unsigned char *) &line, (sizeof (line)-1));
1489 : 0 : dump (eb);
1490 : 0 : M2Error_InternalError ((const char *) m, _m_high);
1491 : 0 : }
1492 : :
1493 : :
1494 : : /*
1495 : : x - checks to see that a=b.
1496 : : */
1497 : :
1498 : 1476961 : static DynamicStrings_String x (DynamicStrings_String a, DynamicStrings_String b)
1499 : : {
1500 : 0 : if (a != b)
1501 : : {
1502 : 0 : M2Error_InternalError ((const char *) "different string returned", 25);
1503 : : }
1504 : 0 : return a;
1505 : : /* static analysis guarentees a RETURN statement will be used before here. */
1506 : : __builtin_unreachable ();
1507 : : }
1508 : :
1509 : :
1510 : : /*
1511 : : IsWhite - returns TRUE if, ch, is a space.
1512 : : */
1513 : :
1514 : 0 : static bool IsWhite (char ch)
1515 : : {
1516 : 0 : return ch == ' ';
1517 : : /* static analysis guarentees a RETURN statement will be used before here. */
1518 : : __builtin_unreachable ();
1519 : : }
1520 : :
1521 : :
1522 : : /*
1523 : : skip - skips over this level input until the next '}'.
1524 : : */
1525 : :
1526 : 1158 : static void skip (M2MetaError_errorBlock *sb)
1527 : : {
1528 : 1158 : int level;
1529 : :
1530 : 1158 : level = 0;
1531 : 19896 : while ((*sb).ini < (*sb).len)
1532 : : {
1533 : 19896 : if ((level == 0) && ((DynamicStrings_char ((*sb).in, (*sb).ini)) == '}'))
1534 : : {
1535 : : return;
1536 : : }
1537 : 18738 : if ((DynamicStrings_char ((*sb).in, (*sb).ini)) == '}')
1538 : : {
1539 : 2892 : level -= 1;
1540 : : }
1541 : 15846 : else if ((DynamicStrings_char ((*sb).in, (*sb).ini)) == '{')
1542 : : {
1543 : : /* avoid dangling else. */
1544 : 2892 : level += 1;
1545 : : }
1546 : 18738 : (*sb).ini += 1;
1547 : : }
1548 : : }
1549 : :
1550 : :
1551 : : /*
1552 : : ifNonNulThen := [ ':' ebnf ] =:
1553 : : */
1554 : :
1555 : 6708 : static void ifNonNulThen (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high)
1556 : : {
1557 : 6708 : unsigned int sym[_sym_high+1];
1558 : :
1559 : : /* make a local copy of each unbounded array. */
1560 : 6708 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1561 : :
1562 : 6708 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == ':')
1563 : : {
1564 : 6708 : (*eb).ini += 1;
1565 : 6708 : if ((*eb).positive)
1566 : : {
1567 : : /* avoid dangling else. */
1568 : 1032 : if ((empty (eb)) && ((DynamicStrings_Length ((*eb).out)) != 0))
1569 : : {
1570 : 0 : M2Printf_printf0 ((const char *) "inconsistency found\\n", 21);
1571 : 0 : dump ((*eb));
1572 : : }
1573 : 6582 : if (empty (eb))
1574 : : {
1575 : 1032 : if (Debugging)
1576 : : {
1577 : : M2Printf_printf0 ((const char *) "empty expression, skip\\n", 24);
1578 : : }
1579 : 1032 : clear (eb);
1580 : : /* skip over this level of input text. */
1581 : 1032 : skip (eb);
1582 : : }
1583 : : else
1584 : : {
1585 : 5550 : if (Debugging)
1586 : : {
1587 : : dump ((*eb));
1588 : : M2Printf_printf0 ((const char *) "non empty expression, clear and continue\\n", 42);
1589 : : }
1590 : 5550 : clear (eb);
1591 : 5550 : if (Debugging)
1592 : : {
1593 : : dump ((*eb));
1594 : : M2Printf_printf0 ((const char *) "cleared, continue\\n", 19);
1595 : : dump ((*eb));
1596 : : }
1597 : : /* carry on processing input text. */
1598 : 5550 : ebnf (eb, (const unsigned int *) sym, _sym_high);
1599 : 5550 : if (Debugging)
1600 : : {
1601 : : M2Printf_printf0 ((const char *) "evaluated\\n", 11);
1602 : : dump ((*eb));
1603 : : }
1604 : : }
1605 : : }
1606 : : else
1607 : : {
1608 : 126 : if (empty (eb))
1609 : : {
1610 : 0 : clear (eb);
1611 : : /* carry on processing input text. */
1612 : 0 : ebnf (eb, (const unsigned int *) sym, _sym_high);
1613 : : }
1614 : : else
1615 : : {
1616 : 126 : clear (eb);
1617 : : /* skip over this level of input text. */
1618 : 126 : skip (eb);
1619 : : }
1620 : : }
1621 : 6708 : if (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
1622 : : {
1623 : 0 : InternalFormat ((*eb), (const char *) "expecting to see }", 18, 852);
1624 : : }
1625 : : }
1626 : 6708 : }
1627 : :
1628 : :
1629 : : /*
1630 : : doNumber -
1631 : : */
1632 : :
1633 : 0 : static void doNumber (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
1634 : : {
1635 : 0 : unsigned int sym[_sym_high+1];
1636 : :
1637 : : /* make a local copy of each unbounded array. */
1638 : 0 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1639 : :
1640 : 0 : if (empty (eb))
1641 : : {
1642 : 0 : (*eb).quotes = false;
1643 : 0 : OutGlyphS (eb, StringConvert_ctos (sym[bol], 0, ' '));
1644 : : }
1645 : 0 : }
1646 : :
1647 : :
1648 : : /*
1649 : : doCount -
1650 : : */
1651 : :
1652 : 2076 : static void doCount (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
1653 : : {
1654 : 2076 : unsigned int sym[_sym_high+1];
1655 : :
1656 : : /* make a local copy of each unbounded array. */
1657 : 2076 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1658 : :
1659 : 2076 : if (empty (eb))
1660 : : {
1661 : 2076 : (*eb).quotes = false;
1662 : 2076 : OutGlyphS (eb, StringConvert_ctos (sym[bol], 0, ' '));
1663 : 2076 : if (((sym[bol] % 100) >= 11) && ((sym[bol] % 100) <= 13))
1664 : : {
1665 : 0 : OutGlyphS (eb, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "th", 2)));
1666 : : }
1667 : :
1668 : : else {
1669 : 2076 : switch (sym[bol] % 10)
1670 : : {
1671 : 1680 : case 1:
1672 : 1680 : OutGlyphS (eb, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "st", 2)));
1673 : 1680 : break;
1674 : :
1675 : 336 : case 2:
1676 : 336 : OutGlyphS (eb, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "nd", 2)));
1677 : 336 : break;
1678 : :
1679 : 24 : case 3:
1680 : 24 : OutGlyphS (eb, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "rd", 2)));
1681 : 24 : break;
1682 : :
1683 : :
1684 : 36 : default:
1685 : 36 : OutGlyphS (eb, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "th", 2)));
1686 : 36 : break;
1687 : : }
1688 : : }
1689 : : }
1690 : 4152 : }
1691 : :
1692 : :
1693 : : /*
1694 : : doCount -
1695 : : */
1696 : :
1697 : 33948 : static void doAscii (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
1698 : : {
1699 : 33948 : unsigned int sym[_sym_high+1];
1700 : :
1701 : : /* make a local copy of each unbounded array. */
1702 : 33948 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1703 : :
1704 : 33906 : if ((((sym[bol] == SymbolTable_NulSym) || (! (empty (eb)))) || (SymbolTable_IsTemporary (sym[bol]))) || (SymbolTable_IsNameAnonymous (sym[bol])))
1705 : : {
1706 : 156 : return;
1707 : : }
1708 : : else
1709 : : {
1710 : 33792 : OutGlyphS (eb, DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym[bol]))));
1711 : : }
1712 : 33948 : }
1713 : :
1714 : :
1715 : : /*
1716 : : unquotedKeyword -
1717 : : */
1718 : :
1719 : 606 : static void unquotedKeyword (M2MetaError_errorBlock *eb)
1720 : : {
1721 : 606 : (*eb).quotes = false;
1722 : 0 : keyword (eb);
1723 : 0 : }
1724 : :
1725 : :
1726 : : /*
1727 : : OutArray -
1728 : : */
1729 : :
1730 : 78 : static void OutArray (M2MetaError_errorBlock *eb, const char *a_, unsigned int _a_high)
1731 : : {
1732 : 78 : char a[_a_high+1];
1733 : :
1734 : : /* make a local copy of each unbounded array. */
1735 : 78 : memcpy (a, a_, _a_high+1);
1736 : :
1737 : 78 : OutGlyphS (eb, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
1738 : 78 : }
1739 : :
1740 : :
1741 : : /*
1742 : : OutGlyphS - outputs a string of glyphs.
1743 : : */
1744 : :
1745 : 77136 : static void OutGlyphS (M2MetaError_errorBlock *eb, DynamicStrings_String s)
1746 : : {
1747 : 77136 : if ((DynamicStrings_Length (s)) > 0)
1748 : : {
1749 : 77136 : flushColor (eb);
1750 : 77136 : checkMe ();
1751 : 77136 : (*eb).glyph = true;
1752 : 77136 : (*eb).out = DynamicStrings_ConCat ((*eb).out, s);
1753 : : }
1754 : 77136 : }
1755 : :
1756 : :
1757 : : /*
1758 : : empty - returns TRUE if the output string is empty.
1759 : : It ignores color changes.
1760 : : */
1761 : :
1762 : 151566 : static bool empty (M2MetaError_errorBlock *eb)
1763 : : {
1764 : 84400 : return ! (*eb).glyph;
1765 : : /* static analysis guarentees a RETURN statement will be used before here. */
1766 : : __builtin_unreachable ();
1767 : : }
1768 : :
1769 : :
1770 : : /*
1771 : : clear - remove the output string.
1772 : : */
1773 : :
1774 : 47386 : static void clear (M2MetaError_errorBlock *eb)
1775 : : {
1776 : 47386 : (*eb).out = DynamicStrings_KillString ((*eb).out);
1777 : 47386 : (*eb).out = DynamicStrings_InitString ((const char *) "", 0);
1778 : 47386 : (*eb).glyph = false;
1779 : 47386 : (*eb).beginCol = M2MetaError_unsetColor;
1780 : 47386 : (*eb).quotes = false;
1781 : 47386 : }
1782 : :
1783 : :
1784 : : /*
1785 : : clear - remove the output string.
1786 : : */
1787 : :
1788 : 27660 : static void doName (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
1789 : : {
1790 : 27660 : unsigned int sym[_sym_high+1];
1791 : :
1792 : : /* make a local copy of each unbounded array. */
1793 : 27660 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1794 : :
1795 : 22218 : if ((((! (empty (eb))) || (sym[bol] == SymbolTable_NulSym)) || (SymbolTable_IsTemporary (sym[bol]))) || (SymbolTable_IsNameAnonymous (sym[bol])))
1796 : : {
1797 : 8238 : return;
1798 : : }
1799 : : else
1800 : : {
1801 : 19422 : if (sym[bol] == M2Base_ZType)
1802 : : {
1803 : 60 : (*eb).quotes = false;
1804 : 60 : OutArray (eb, (const char *) "the ZType", 9);
1805 : : }
1806 : 19362 : else if (sym[bol] == M2Base_RType)
1807 : : {
1808 : : /* avoid dangling else. */
1809 : 18 : (*eb).quotes = false;
1810 : 18 : OutArray (eb, (const char *) "the RType", 9);
1811 : : }
1812 : : else
1813 : : {
1814 : : /* avoid dangling else. */
1815 : 19344 : doAscii (eb, (const unsigned int *) sym, _sym_high, bol);
1816 : : }
1817 : : }
1818 : 27660 : }
1819 : :
1820 : :
1821 : : /*
1822 : : clear - remove the output string.
1823 : : */
1824 : :
1825 : 0 : static void doQualified (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
1826 : : {
1827 : 0 : typedef struct doQualified__T3_a doQualified__T3;
1828 : :
1829 : 0 : struct doQualified__T3_a { unsigned int array[1+1]; };
1830 : 0 : doQualified__T3 mod;
1831 : 0 : unsigned int sym[_sym_high+1];
1832 : :
1833 : : /* make a local copy of each unbounded array. */
1834 : 0 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1835 : :
1836 : 0 : if ((((! (empty (eb))) || (sym[bol] == SymbolTable_NulSym)) || (SymbolTable_IsTemporary (sym[bol]))) || (SymbolTable_IsNameAnonymous (sym[bol])))
1837 : : {
1838 : 0 : return;
1839 : : }
1840 : : else
1841 : : {
1842 : 0 : mod.array[0] = SymbolTable_GetScope (sym[bol]);
1843 : 0 : if ((SymbolTable_IsDefImp (mod.array[0])) && (SymbolTable_IsExported (mod.array[0], sym[bol])))
1844 : : {
1845 : 0 : doAscii (eb, (const unsigned int *) &mod.array[0], 1, 0);
1846 : 0 : OutArray (eb, (const char *) ".", 1);
1847 : 0 : OutGlyphS (eb, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym[bol])))));
1848 : : }
1849 : : else
1850 : : {
1851 : 0 : doAscii (eb, (const unsigned int *) sym, _sym_high, bol);
1852 : : }
1853 : : }
1854 : 0 : }
1855 : :
1856 : :
1857 : : /*
1858 : : doType - returns a string containing the type name of
1859 : : sym.
1860 : : */
1861 : :
1862 : 14586 : static void doType (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
1863 : : {
1864 : 14586 : unsigned int sym[_sym_high+1];
1865 : :
1866 : : /* make a local copy of each unbounded array. */
1867 : 14586 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1868 : :
1869 : 14580 : if ((! (empty (eb))) || (sym[bol] == SymbolTable_NulSym))
1870 : : {
1871 : 6 : return;
1872 : : }
1873 : : else
1874 : : {
1875 : 14580 : const_cast<unsigned int *>(sym)[bol] = SymbolTable_GetType (sym[bol]);
1876 : 14580 : doAscii (eb, (const unsigned int *) sym, _sym_high, bol);
1877 : : }
1878 : 14586 : }
1879 : :
1880 : :
1881 : : /*
1882 : : doSkipType - will skip all pseudonym types. It also
1883 : : returns the type symbol found and name.
1884 : : */
1885 : :
1886 : 9414 : static void doSkipType (M2MetaError_errorBlock eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
1887 : : {
1888 : 9414 : unsigned int sym[_sym_high+1];
1889 : :
1890 : : /* make a local copy of each unbounded array. */
1891 : 9414 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
1892 : :
1893 : 24 : if ((! (empty (&eb))) || (sym[bol] == SymbolTable_NulSym))
1894 : : {
1895 : 9390 : return;
1896 : : }
1897 : : else
1898 : : {
1899 : 24 : const_cast<unsigned int *>(sym)[bol] = SymbolTable_SkipType (sym[bol]);
1900 : 24 : while ((SymbolTable_IsType (sym[bol])) && (((SymbolTable_GetSymName (sym[bol])) == NameKey_NulName) || (SymbolTable_IsNameAnonymous (sym[bol]))))
1901 : : {
1902 : 0 : const_cast<unsigned int *>(sym)[bol] = SymbolTable_GetType (sym[bol]);
1903 : : }
1904 : 24 : doAscii (&eb, (const unsigned int *) sym, _sym_high, bol);
1905 : : }
1906 : 9414 : }
1907 : :
1908 : :
1909 : : /*
1910 : : doGetType - attempts to get the type of sym[bol].
1911 : : */
1912 : :
1913 : 0 : static void doGetType (M2MetaError_errorBlock *eb, unsigned int *sym, unsigned int _sym_high, unsigned int bol)
1914 : : {
1915 : 0 : if (((bol > _sym_high) || (! (empty (eb)))) || (sym[bol] == SymbolTable_NulSym))
1916 : : {
1917 : : return;
1918 : : }
1919 : : else
1920 : : {
1921 : 0 : const_cast<unsigned int *>(sym)[bol] = SymbolTable_GetType (sym[bol]);
1922 : : }
1923 : : }
1924 : :
1925 : :
1926 : : /*
1927 : : doGetSkipType - will skip all pseudonym types. It also
1928 : : returns the type symbol found and name.
1929 : : */
1930 : :
1931 : 0 : static void doGetSkipType (M2MetaError_errorBlock *eb, unsigned int *sym, unsigned int _sym_high, unsigned int bol)
1932 : : {
1933 : 0 : unsigned int prev;
1934 : :
1935 : 0 : if (((bol > _sym_high) || (! (empty (eb)))) || (sym[bol] == SymbolTable_NulSym))
1936 : : {
1937 : : return;
1938 : : }
1939 : : else
1940 : : {
1941 : 0 : do {
1942 : 0 : prev = sym[bol];
1943 : 0 : const_cast<unsigned int *>(sym)[bol] = SymbolTable_SkipType (sym[bol]);
1944 : 0 : if (((SymbolTable_IsType (sym[bol])) && (((SymbolTable_GetSymName (sym[bol])) == NameKey_NulName) || (SymbolTable_IsNameAnonymous (sym[bol])))) && ((SymbolTable_GetType (sym[bol])) != SymbolTable_NulSym))
1945 : : {
1946 : 0 : const_cast<unsigned int *>(sym)[bol] = SymbolTable_GetType (sym[bol]);
1947 : : }
1948 : 0 : } while (! (sym[bol] == prev));
1949 : : }
1950 : : }
1951 : :
1952 : :
1953 : : /*
1954 : : doChain -
1955 : : */
1956 : :
1957 : 162 : static void doChain (M2MetaError_errorBlock *eb, unsigned int tok)
1958 : : {
1959 : 162 : if (lastRoot == NULL)
1960 : : {
1961 : 0 : M2Error_InternalError ((const char *) "should not be chaining an error onto an empty error note", 56);
1962 : : }
1963 : : else
1964 : : {
1965 : 162 : (*eb).e = M2Error_ChainError (tok, lastRoot);
1966 : : }
1967 : 162 : }
1968 : :
1969 : :
1970 : : /*
1971 : : doError - creates and returns an error note.
1972 : : */
1973 : :
1974 : 3110 : static void doError (M2MetaError_errorBlock *eb, unsigned int tok)
1975 : : {
1976 : 0 : if ((*eb).useError)
1977 : : {
1978 : 3110 : chooseError (eb, tok);
1979 : : }
1980 : 0 : }
1981 : :
1982 : :
1983 : : /*
1984 : : defaultError - adds the default error location to, tok, if one has not already been
1985 : : assigned.
1986 : : */
1987 : :
1988 : 3104 : static void defaultError (M2MetaError_errorBlock *eb, unsigned int tok)
1989 : : {
1990 : 3104 : if ((*eb).e == NULL)
1991 : : {
1992 : 2320 : doError (eb, tok);
1993 : : }
1994 : 3104 : }
1995 : :
1996 : :
1997 : : /*
1998 : : chooseError - choose the error kind dependant upon type.
1999 : : Either an error, warning or note will be generated.
2000 : : */
2001 : :
2002 : 3110 : static void chooseError (M2MetaError_errorBlock *eb, unsigned int tok)
2003 : : {
2004 : 3110 : if ((*eb).chain)
2005 : : {
2006 : 48 : doChain (eb, tok);
2007 : : }
2008 : : else
2009 : : {
2010 : 3062 : switch ((*eb).type)
2011 : : {
2012 : 114 : case M2MetaError_chained:
2013 : 114 : doChain (eb, tok);
2014 : 114 : break;
2015 : :
2016 : 2335 : case M2MetaError_none:
2017 : 2335 : case M2MetaError_aborta:
2018 : 2335 : case M2MetaError_error:
2019 : 2335 : if ((*eb).e == NULL)
2020 : : {
2021 : 2335 : (*eb).e = M2Error_NewError (tok);
2022 : : }
2023 : : else
2024 : : {
2025 : 0 : (*eb).e = M2Error_MoveError ((*eb).e, tok);
2026 : : }
2027 : : break;
2028 : :
2029 : 594 : case M2MetaError_warning:
2030 : 594 : if ((*eb).e == NULL)
2031 : : {
2032 : 594 : (*eb).e = M2Error_NewWarning (tok);
2033 : : }
2034 : : else
2035 : : {
2036 : 0 : (*eb).e = M2Error_MoveError ((*eb).e, tok);
2037 : : }
2038 : : break;
2039 : :
2040 : 19 : case M2MetaError_note:
2041 : 19 : if ((*eb).e == NULL)
2042 : : {
2043 : 19 : (*eb).e = M2Error_NewNote (tok);
2044 : : }
2045 : : else
2046 : : {
2047 : 0 : (*eb).e = M2Error_MoveError ((*eb).e, tok);
2048 : : }
2049 : : break;
2050 : :
2051 : :
2052 : 0 : default:
2053 : 0 : M2Error_InternalError ((const char *) "unexpected enumeration value", 28);
2054 : 3110 : break;
2055 : : }
2056 : : }
2057 : 3110 : if ((*eb).root)
2058 : : {
2059 : 42 : lastRoot = (*eb).e;
2060 : 42 : lastColor = findColorType ((*eb).in);
2061 : : }
2062 : 3110 : (*eb).e = M2Error_SetColor ((*eb).e);
2063 : 3110 : }
2064 : :
2065 : :
2066 : : /*
2067 : : doErrorScopeModule -
2068 : : */
2069 : :
2070 : 36 : static void doErrorScopeModule (M2MetaError_errorBlock *eb, unsigned int sym)
2071 : : {
2072 : 36 : unsigned int scope;
2073 : :
2074 : 36 : scope = SymbolTable_GetScope (sym);
2075 : 36 : if (SymbolTable_IsModule (scope))
2076 : : {
2077 : 30 : if (SymbolTable_IsInnerModule (scope))
2078 : : {
2079 : 0 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2080 : : }
2081 : : else
2082 : : {
2083 : 30 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2084 : : }
2085 : : }
2086 : : else
2087 : : {
2088 : 6 : M2Debug_Assert (SymbolTable_IsDefImp (scope));
2089 : : /* if this fails then we need to skip to the outer scope.
2090 : : REPEAT
2091 : : OuterModule := GetScope(OuterModule)
2092 : : UNTIL GetScope(OuterModule)=NulSym. */
2093 : 6 : if ((SymbolTable_GetDeclaredModule (sym)) == M2LexBuf_UnknownTokenNo)
2094 : : {
2095 : 0 : doError (eb, SymbolTable_GetDeclaredDef (sym));
2096 : : }
2097 : : else
2098 : : {
2099 : 6 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2100 : : }
2101 : : }
2102 : 36 : }
2103 : :
2104 : :
2105 : : /*
2106 : : doErrorScopeForward -
2107 : : */
2108 : :
2109 : 0 : static void doErrorScopeForward (M2MetaError_errorBlock *eb, unsigned int sym)
2110 : : {
2111 : 0 : unsigned int scope;
2112 : :
2113 : 0 : scope = SymbolTable_GetScope (sym);
2114 : 0 : if (SymbolTable_IsModule (scope))
2115 : : {
2116 : 0 : if (SymbolTable_IsInnerModule (scope))
2117 : : {
2118 : 0 : doError (eb, SymbolTable_GetDeclaredFor (sym));
2119 : : }
2120 : : else
2121 : : {
2122 : 0 : doError (eb, SymbolTable_GetDeclaredFor (sym));
2123 : : }
2124 : : }
2125 : : else
2126 : : {
2127 : 0 : M2Debug_Assert (SymbolTable_IsDefImp (scope));
2128 : : /* if this fails then we need to skip to the outer scope.
2129 : : REPEAT
2130 : : OuterModule := GetScope(OuterModule)
2131 : : UNTIL GetScope(OuterModule)=NulSym. */
2132 : 0 : if ((SymbolTable_GetDeclaredModule (sym)) == M2LexBuf_UnknownTokenNo)
2133 : : {
2134 : 0 : doError (eb, SymbolTable_GetDeclaredDef (sym));
2135 : : }
2136 : : else
2137 : : {
2138 : 0 : doError (eb, SymbolTable_GetDeclaredFor (sym));
2139 : : }
2140 : : }
2141 : 0 : }
2142 : :
2143 : :
2144 : : /*
2145 : : doErrorScopeMod - potentially create an error referring to the definition
2146 : : module, fall back to the implementation or program module if
2147 : : there is no declaration in the definition module.
2148 : : */
2149 : :
2150 : 52 : static void doErrorScopeMod (M2MetaError_errorBlock *eb, unsigned int sym)
2151 : : {
2152 : 52 : unsigned int scope;
2153 : :
2154 : 52 : scope = SymbolTable_GetScope (sym);
2155 : 52 : if (scope == SymbolTable_NulSym)
2156 : : {
2157 : 16 : M2Error_EnterErrorScope (static_cast<M2Error_ErrorScope> (NULL));
2158 : 16 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2159 : : }
2160 : : else
2161 : : {
2162 : 36 : M2Error_EnterErrorScope (SymbolTable_GetErrorScope (scope));
2163 : 36 : if (SymbolTable_IsProcedure (scope))
2164 : : {
2165 : 0 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2166 : : }
2167 : : else
2168 : : {
2169 : 36 : doErrorScopeModule (eb, sym);
2170 : : }
2171 : : }
2172 : 52 : M2Error_LeaveErrorScope ();
2173 : 52 : }
2174 : :
2175 : :
2176 : : /*
2177 : : doErrorScopeFor - potentially create an error referring to the
2178 : : forward declaration, definition module, fall back
2179 : : to the implementation or program module if
2180 : : there is no declaration in the definition module.
2181 : : */
2182 : :
2183 : 0 : static void doErrorScopeFor (M2MetaError_errorBlock *eb, unsigned int sym)
2184 : : {
2185 : 0 : unsigned int scope;
2186 : :
2187 : 0 : scope = SymbolTable_GetScope (sym);
2188 : 0 : if (scope == SymbolTable_NulSym)
2189 : : {
2190 : 0 : M2Error_EnterErrorScope (static_cast<M2Error_ErrorScope> (NULL));
2191 : 0 : doError (eb, SymbolTable_GetDeclaredFor (sym));
2192 : : }
2193 : : else
2194 : : {
2195 : 0 : M2Error_EnterErrorScope (SymbolTable_GetErrorScope (scope));
2196 : 0 : if (SymbolTable_IsProcedure (scope))
2197 : : {
2198 : 0 : doError (eb, SymbolTable_GetDeclaredFor (sym));
2199 : : }
2200 : : else
2201 : : {
2202 : 0 : doErrorScopeForward (eb, sym);
2203 : : }
2204 : : }
2205 : 0 : M2Error_LeaveErrorScope ();
2206 : 0 : }
2207 : :
2208 : 52 : static void declaredMod (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2209 : : {
2210 : 52 : unsigned int sym[_sym_high+1];
2211 : :
2212 : : /* make a local copy of each unbounded array. */
2213 : 52 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2214 : :
2215 : : /*
2216 : : doDeclaredMod - creates an error note where sym[bol] was declared.
2217 : : */
2218 : 52 : if (bol <= _sym_high)
2219 : : {
2220 : 52 : doErrorScopeMod (eb, sym[bol]);
2221 : : }
2222 : 52 : }
2223 : :
2224 : :
2225 : : /*
2226 : : doErrorScopeDefinition - use the declaration in the definitio module if one is available.
2227 : : */
2228 : :
2229 : 402 : static void doErrorScopeDefinition (M2MetaError_errorBlock *eb, unsigned int sym)
2230 : : {
2231 : 402 : unsigned int scope;
2232 : :
2233 : 402 : scope = SymbolTable_GetScope (sym);
2234 : 402 : if (SymbolTable_IsModule (scope))
2235 : : {
2236 : : /* No definition module for a program module. */
2237 : 402 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2238 : : }
2239 : : else
2240 : : {
2241 : 0 : M2Debug_Assert (SymbolTable_IsDefImp (scope));
2242 : 0 : if ((SymbolTable_GetDeclaredDefinition (sym)) == M2LexBuf_UnknownTokenNo)
2243 : : {
2244 : : /* Fall back to the implementation module if no declaration exists
2245 : : in the definition module. */
2246 : 0 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2247 : : }
2248 : : else
2249 : : {
2250 : 0 : doError (eb, SymbolTable_GetDeclaredDef (sym));
2251 : : }
2252 : : }
2253 : 402 : }
2254 : :
2255 : :
2256 : : /*
2257 : : doErrorScopeDef - potentially create an error referring to the definition
2258 : : module, fall back to the implementation or program module if
2259 : : there is no declaration in the definition module.
2260 : : */
2261 : :
2262 : 432 : static void doErrorScopeDef (M2MetaError_errorBlock *eb, unsigned int sym)
2263 : : {
2264 : 432 : unsigned int scope;
2265 : :
2266 : 432 : scope = SymbolTable_GetScope (sym);
2267 : 432 : if (scope == SymbolTable_NulSym)
2268 : : {
2269 : 0 : M2Error_EnterErrorScope (static_cast<M2Error_ErrorScope> (NULL));
2270 : 0 : doError (eb, SymbolTable_GetDeclaredFor (sym));
2271 : : }
2272 : : else
2273 : : {
2274 : 432 : M2Error_EnterErrorScope (SymbolTable_GetErrorScope (scope));
2275 : 432 : if (SymbolTable_IsProcedure (scope))
2276 : : {
2277 : 30 : doError (eb, SymbolTable_GetDeclaredDef (sym));
2278 : : }
2279 : : else
2280 : : {
2281 : 402 : doErrorScopeDefinition (eb, sym);
2282 : : }
2283 : : }
2284 : 432 : M2Error_LeaveErrorScope ();
2285 : 432 : }
2286 : :
2287 : 432 : static void declaredDef (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2288 : : {
2289 : 432 : unsigned int sym[_sym_high+1];
2290 : :
2291 : : /* make a local copy of each unbounded array. */
2292 : 432 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2293 : :
2294 : : /*
2295 : : doDeclaredDef - creates an error note where sym[bol] was declared.
2296 : : */
2297 : 432 : if (bol <= _sym_high)
2298 : : {
2299 : 432 : doErrorScopeDef (eb, sym[bol]);
2300 : : }
2301 : 432 : }
2302 : :
2303 : 0 : static void declaredFor (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2304 : : {
2305 : 0 : unsigned int sym[_sym_high+1];
2306 : :
2307 : : /* make a local copy of each unbounded array. */
2308 : 0 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2309 : :
2310 : : /*
2311 : : doDeclaredFor - creates an error note where sym[bol] was declared.
2312 : : */
2313 : 0 : if (bol <= _sym_high)
2314 : : {
2315 : 0 : doErrorScopeFor (eb, sym[bol]);
2316 : : }
2317 : 0 : }
2318 : :
2319 : :
2320 : : /*
2321 : : doErrorScopeProc - determine the location for the error or warning from
2322 : : the default declaration. For example parameters can be
2323 : : declared in definition, forward or in modules (proper procedure).
2324 : : Use GetVarParamTok to obtain a variable or parameter location.
2325 : : */
2326 : :
2327 : 144 : static void doErrorScopeProc (M2MetaError_errorBlock *eb, unsigned int sym, M2MetaError_GetTokProcedure GetVarParamTok)
2328 : : {
2329 : 144 : unsigned int scope;
2330 : :
2331 : 144 : scope = SymbolTable_GetScope (sym);
2332 : 144 : if (scope == SymbolTable_NulSym)
2333 : : {
2334 : 60 : M2Error_EnterErrorScope (static_cast<M2Error_ErrorScope> (NULL));
2335 : 60 : doError (eb, SymbolTable_GetDeclaredDef (sym));
2336 : : }
2337 : : else
2338 : : {
2339 : 84 : M2Error_EnterErrorScope (SymbolTable_GetErrorScope (scope));
2340 : 84 : if ((SymbolTable_IsVar (sym)) || (SymbolTable_IsParameter (sym)))
2341 : : {
2342 : 84 : doError (eb, (unsigned int ) ((*GetVarParamTok.proc) (sym)));
2343 : : }
2344 : 0 : else if (SymbolTable_IsProcedure (scope))
2345 : : {
2346 : : /* avoid dangling else. */
2347 : 0 : doError (eb, SymbolTable_GetDeclaredDef (sym));
2348 : : }
2349 : 0 : else if (SymbolTable_IsModule (scope))
2350 : : {
2351 : : /* avoid dangling else. */
2352 : 0 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2353 : : }
2354 : : else
2355 : : {
2356 : : /* avoid dangling else. */
2357 : 0 : M2Debug_Assert (SymbolTable_IsDefImp (scope));
2358 : 0 : if ((SymbolTable_GetDeclaredDefinition (sym)) == M2LexBuf_UnknownTokenNo)
2359 : : {
2360 : 0 : doError (eb, SymbolTable_GetDeclaredMod (sym));
2361 : : }
2362 : : else
2363 : : {
2364 : 0 : doError (eb, SymbolTable_GetDeclaredDef (sym));
2365 : : }
2366 : : }
2367 : : }
2368 : 144 : M2Error_LeaveErrorScope ();
2369 : 144 : }
2370 : :
2371 : 84 : static void declaredVar (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2372 : : {
2373 : 84 : unsigned int sym[_sym_high+1];
2374 : :
2375 : : /* make a local copy of each unbounded array. */
2376 : 84 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2377 : :
2378 : : /*
2379 : : doDeclaredVar - creates an error note where sym[bol] was declared.
2380 : : */
2381 : 84 : if (bol <= _sym_high)
2382 : : {
2383 : 84 : doErrorScopeProc (eb, sym[bol], (M2MetaError_GetTokProcedure) {(M2MetaError_GetTokProcedure_t) SymbolTable_GetVarDeclTok});
2384 : : }
2385 : 84 : }
2386 : :
2387 : 0 : static void declaredType (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2388 : : {
2389 : 0 : unsigned int sym[_sym_high+1];
2390 : :
2391 : : /* make a local copy of each unbounded array. */
2392 : 0 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2393 : :
2394 : : /*
2395 : : doDeclaredType - creates an error note where sym[bol] was declared.
2396 : : */
2397 : 0 : if (bol <= _sym_high)
2398 : : {
2399 : 0 : doErrorScopeProc (eb, sym[bol], (M2MetaError_GetTokProcedure) {(M2MetaError_GetTokProcedure_t) SymbolTable_GetVarDeclTypeTok});
2400 : : }
2401 : 0 : }
2402 : :
2403 : 60 : static void declaredFull (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2404 : : {
2405 : 60 : unsigned int sym[_sym_high+1];
2406 : :
2407 : : /* make a local copy of each unbounded array. */
2408 : 60 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2409 : :
2410 : : /*
2411 : : doDeclaredFull - creates an error note where sym[bol] was declared.
2412 : : */
2413 : 60 : if (bol <= _sym_high)
2414 : : {
2415 : 60 : doErrorScopeProc (eb, sym[bol], (M2MetaError_GetTokProcedure) {(M2MetaError_GetTokProcedure_t) SymbolTable_GetVarDeclFullTok});
2416 : : }
2417 : 60 : }
2418 : :
2419 : :
2420 : : /*
2421 : : used - creates an error note where sym[bol] was first used.
2422 : : */
2423 : :
2424 : 162 : static void used (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2425 : : {
2426 : 162 : unsigned int sym[_sym_high+1];
2427 : :
2428 : : /* make a local copy of each unbounded array. */
2429 : 162 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2430 : :
2431 : 162 : if (bol <= _sym_high)
2432 : : {
2433 : 162 : doError (eb, SymbolTable_GetFirstUsed (sym[bol]));
2434 : : }
2435 : 162 : }
2436 : :
2437 : :
2438 : : /*
2439 : : symDesc -
2440 : : */
2441 : :
2442 : 1056 : static DynamicStrings_String symDesc (unsigned int sym)
2443 : : {
2444 : 1056 : if (SymbolTable_IsConstLit (sym))
2445 : : {
2446 : 6 : return DynamicStrings_InitString ((const char *) "constant literal", 16);
2447 : : }
2448 : 1050 : else if (SymbolTable_IsConstSet (sym))
2449 : : {
2450 : : /* avoid dangling else. */
2451 : 48 : return DynamicStrings_InitString ((const char *) "constant set", 12);
2452 : : }
2453 : 1002 : else if (SymbolTable_IsConstructor (sym))
2454 : : {
2455 : : /* avoid dangling else. */
2456 : 12 : return DynamicStrings_InitString ((const char *) "constructor", 11);
2457 : : }
2458 : 990 : else if (SymbolTable_IsConst (sym))
2459 : : {
2460 : : /* avoid dangling else. */
2461 : 24 : return DynamicStrings_InitString ((const char *) "constant", 8);
2462 : : }
2463 : 966 : else if (SymbolTable_IsArray (sym))
2464 : : {
2465 : : /* avoid dangling else. */
2466 : 72 : return DynamicStrings_InitString ((const char *) "array", 5);
2467 : : }
2468 : 894 : else if (SymbolTable_IsVar (sym))
2469 : : {
2470 : : /* avoid dangling else. */
2471 : 588 : if (SymbolTable_IsTemporary (sym))
2472 : : {
2473 : 432 : return DynamicStrings_InitString ((const char *) "expression", 10);
2474 : : }
2475 : : else
2476 : : {
2477 : 156 : return DynamicStrings_InitString ((const char *) "variable", 8);
2478 : : }
2479 : : }
2480 : 306 : else if (SymbolTable_IsEnumeration (sym))
2481 : : {
2482 : : /* avoid dangling else. */
2483 : 6 : return DynamicStrings_InitString ((const char *) "enumeration type", 16);
2484 : : }
2485 : 300 : else if (SymbolTable_IsFieldEnumeration (sym))
2486 : : {
2487 : : /* avoid dangling else. */
2488 : 0 : return DynamicStrings_InitString ((const char *) "enumeration field", 17);
2489 : : }
2490 : 300 : else if (SymbolTable_IsUnbounded (sym))
2491 : : {
2492 : : /* avoid dangling else. */
2493 : 24 : return DynamicStrings_InitString ((const char *) "unbounded parameter", 19);
2494 : : }
2495 : 276 : else if (SymbolTable_IsProcType (sym))
2496 : : {
2497 : : /* avoid dangling else. */
2498 : 12 : return DynamicStrings_InitString ((const char *) "procedure type", 14);
2499 : : }
2500 : 264 : else if (M2Base_IsPseudoBaseFunction (sym))
2501 : : {
2502 : : /* avoid dangling else. */
2503 : 6 : return DynamicStrings_InitString ((const char *) "standard function procedure", 27);
2504 : : }
2505 : 258 : else if (M2Base_IsPseudoBaseProcedure (sym))
2506 : : {
2507 : : /* avoid dangling else. */
2508 : 0 : return DynamicStrings_InitString ((const char *) "standard procedure", 18);
2509 : : }
2510 : 258 : else if (SymbolTable_IsProcedure (sym))
2511 : : {
2512 : : /* avoid dangling else. */
2513 : 18 : return DynamicStrings_InitString ((const char *) "procedure", 9);
2514 : : }
2515 : 240 : else if (SymbolTable_IsPointer (sym))
2516 : : {
2517 : : /* avoid dangling else. */
2518 : 0 : return DynamicStrings_InitString ((const char *) "pointer", 7);
2519 : : }
2520 : 240 : else if (SymbolTable_IsParameter (sym))
2521 : : {
2522 : : /* avoid dangling else. */
2523 : 18 : if (SymbolTable_IsParameterVar (sym))
2524 : : {
2525 : 12 : return DynamicStrings_InitString ((const char *) "var parameter", 13);
2526 : : }
2527 : : else
2528 : : {
2529 : 6 : return DynamicStrings_InitString ((const char *) "parameter", 9);
2530 : : }
2531 : : }
2532 : 222 : else if (SymbolTable_IsType (sym))
2533 : : {
2534 : : /* avoid dangling else. */
2535 : 0 : if (SymbolTable_IsHiddenType (sym))
2536 : : {
2537 : 0 : return DynamicStrings_InitString ((const char *) "opaque type", 11);
2538 : : }
2539 : : else
2540 : : {
2541 : 0 : return DynamicStrings_InitString ((const char *) "type", 4);
2542 : : }
2543 : : }
2544 : 222 : else if (SymbolTable_IsRecord (sym))
2545 : : {
2546 : : /* avoid dangling else. */
2547 : 6 : return DynamicStrings_InitString ((const char *) "record", 6);
2548 : : }
2549 : 216 : else if (SymbolTable_IsRecordField (sym))
2550 : : {
2551 : : /* avoid dangling else. */
2552 : 0 : return DynamicStrings_InitString ((const char *) "record field", 12);
2553 : : }
2554 : 216 : else if (SymbolTable_IsVarient (sym))
2555 : : {
2556 : : /* avoid dangling else. */
2557 : 0 : return DynamicStrings_InitString ((const char *) "varient record", 14);
2558 : : }
2559 : 216 : else if (SymbolTable_IsModule (sym))
2560 : : {
2561 : : /* avoid dangling else. */
2562 : 0 : return DynamicStrings_InitString ((const char *) "module", 6);
2563 : : }
2564 : 216 : else if (SymbolTable_IsDefImp (sym))
2565 : : {
2566 : : /* avoid dangling else. */
2567 : 0 : return DynamicStrings_InitString ((const char *) "definition or implementation module", 35);
2568 : : }
2569 : 216 : else if (SymbolTable_IsSet (sym))
2570 : : {
2571 : : /* avoid dangling else. */
2572 : 72 : return DynamicStrings_InitString ((const char *) "set", 3);
2573 : : }
2574 : 144 : else if (SymbolTable_IsUnknown (sym))
2575 : : {
2576 : : /* avoid dangling else. */
2577 : 18 : return DynamicStrings_InitString ((const char *) "an unknown", 10);
2578 : : }
2579 : 126 : else if (SymbolTable_IsSubrange (sym))
2580 : : {
2581 : : /* avoid dangling else. */
2582 : 126 : return DynamicStrings_InitString ((const char *) "subrange", 8);
2583 : : }
2584 : : else
2585 : : {
2586 : : /* avoid dangling else. */
2587 : 0 : return DynamicStrings_InitString ((const char *) "", 0);
2588 : : }
2589 : : /* static analysis guarentees a RETURN statement will be used before here. */
2590 : : __builtin_unreachable ();
2591 : : }
2592 : :
2593 : :
2594 : : /*
2595 : : doDesc -
2596 : : */
2597 : :
2598 : 8900 : static void doDesc (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2599 : : {
2600 : 8900 : unsigned int sym[_sym_high+1];
2601 : :
2602 : : /* make a local copy of each unbounded array. */
2603 : 8900 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2604 : :
2605 : 8900 : if (empty (eb))
2606 : : {
2607 : 1056 : OutGlyphS (eb, symDesc (sym[bol]));
2608 : 1056 : if (! (empty (eb)))
2609 : : {
2610 : 1056 : (*eb).quotes = false;
2611 : : }
2612 : : }
2613 : 8900 : }
2614 : :
2615 : :
2616 : : /*
2617 : : op := {'!'|'a'|'c'|'d'|'k'|'n'|'p'|'q'|'s'|'t'|'u'|
2618 : : 'A'|'B'|'C'|'D'|'E'|'F'|'G'|'H'|'K'|'M'|'N'|
2619 : : 'O'|'P'|'Q'|'R'|'S'|'T'|'U'|'V'|'W'|'X'|'Y'|'Z'} then =:
2620 : : */
2621 : :
2622 : 40678 : static void op (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high, unsigned int bol)
2623 : : {
2624 : 40678 : unsigned int sym[_sym_high+1];
2625 : :
2626 : : /* make a local copy of each unbounded array. */
2627 : 40678 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2628 : :
2629 : 124589 : while (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
2630 : : {
2631 : 83911 : if (Debugging)
2632 : : {
2633 : : M2Printf_printf0 ((const char *) "while loop in op\\n", 18);
2634 : : dump ((*eb));
2635 : : }
2636 : 83911 : switch (DynamicStrings_char ((*eb).in, (*eb).ini))
2637 : : {
2638 : 0 : case '!':
2639 : 0 : (*eb).positive = ! (*eb).positive;
2640 : 0 : break;
2641 : :
2642 : 27660 : case 'a':
2643 : 27660 : doName (eb, (const unsigned int *) sym, _sym_high, bol);
2644 : 27660 : break;
2645 : :
2646 : 0 : case 'c':
2647 : 0 : (*eb).currentCol = readColor (eb);
2648 : 0 : (*eb).ini -= 1;
2649 : 0 : break;
2650 : :
2651 : 8900 : case 'd':
2652 : 8900 : doDesc (eb, (const unsigned int *) sym, _sym_high, bol);
2653 : 8900 : break;
2654 : :
2655 : 606 : case 'k':
2656 : 606 : unquotedKeyword (eb);
2657 : 606 : (*eb).ini -= 1;
2658 : 606 : break;
2659 : :
2660 : 0 : case 'n':
2661 : 0 : doNumber (eb, (const unsigned int *) sym, _sym_high, bol);
2662 : 0 : break;
2663 : :
2664 : 0 : case 'p':
2665 : 0 : popColor (eb);
2666 : 0 : break;
2667 : :
2668 : 0 : case 'q':
2669 : 0 : doQualified (eb, (const unsigned int *) sym, _sym_high, bol);
2670 : 0 : break;
2671 : :
2672 : 9414 : case 's':
2673 : 9414 : doSkipType ((*eb), (const unsigned int *) sym, _sym_high, bol);
2674 : 9414 : break;
2675 : :
2676 : 14586 : case 't':
2677 : 14586 : doType (eb, (const unsigned int *) sym, _sym_high, bol);
2678 : 14586 : break;
2679 : :
2680 : 0 : case 'u':
2681 : 0 : (*eb).quotes = false;
2682 : 0 : break;
2683 : :
2684 : 82 : case 'A':
2685 : 82 : (*eb).type = M2MetaError_aborta;
2686 : 82 : seenAbort = true;
2687 : 82 : break;
2688 : :
2689 : 0 : case 'B':
2690 : 0 : declaredType (eb, (const unsigned int *) sym, _sym_high, bol);
2691 : 0 : break;
2692 : :
2693 : 42 : case 'C':
2694 : 42 : (*eb).chain = true;
2695 : 42 : break;
2696 : :
2697 : 432 : case 'D':
2698 : 432 : declaredDef (eb, (const unsigned int *) sym, _sym_high, bol);
2699 : 432 : break;
2700 : :
2701 : 1938 : case 'E':
2702 : 1938 : (*eb).type = M2MetaError_error;
2703 : 1938 : break;
2704 : :
2705 : 0 : case 'F':
2706 : 0 : filename (eb);
2707 : 0 : (*eb).ini -= 1;
2708 : 0 : break;
2709 : :
2710 : 0 : case 'G':
2711 : 0 : declaredFor (eb, (const unsigned int *) sym, _sym_high, bol);
2712 : 0 : break;
2713 : :
2714 : 60 : case 'H':
2715 : 60 : declaredFull (eb, (const unsigned int *) sym, _sym_high, bol);
2716 : 60 : break;
2717 : :
2718 : 546 : case 'K':
2719 : 546 : keyword (eb);
2720 : 546 : (*eb).ini -= 1;
2721 : 546 : break;
2722 : :
2723 : 52 : case 'M':
2724 : 52 : declaredMod (eb, (const unsigned int *) sym, _sym_high, bol);
2725 : 52 : break;
2726 : :
2727 : 2076 : case 'N':
2728 : 2076 : doCount (eb, (const unsigned int *) sym, _sym_high, bol);
2729 : 2076 : break;
2730 : :
2731 : 19 : case 'O':
2732 : 19 : (*eb).type = M2MetaError_note;
2733 : 19 : break;
2734 : :
2735 : 0 : case 'P':
2736 : 0 : pushColor (eb);
2737 : 0 : break;
2738 : :
2739 : 0 : case 'Q':
2740 : 0 : resetDictionary ();
2741 : 0 : break;
2742 : :
2743 : 42 : case 'R':
2744 : 42 : (*eb).root = true;
2745 : 42 : break;
2746 : :
2747 : 0 : case 'S':
2748 : 0 : doGetSkipType (eb, (unsigned int *) sym, _sym_high, bol);
2749 : 0 : break;
2750 : :
2751 : 0 : case 'T':
2752 : 0 : doGetType (eb, (unsigned int *) sym, _sym_high, bol);
2753 : 0 : break;
2754 : :
2755 : 162 : case 'U':
2756 : 162 : used (eb, (const unsigned int *) sym, _sym_high, bol);
2757 : 162 : break;
2758 : :
2759 : 84 : case 'V':
2760 : 84 : declaredVar (eb, (const unsigned int *) sym, _sym_high, bol);
2761 : 84 : break;
2762 : :
2763 : 10502 : case 'W':
2764 : 10502 : (*eb).type = M2MetaError_warning;
2765 : 10502 : break;
2766 : :
2767 : 0 : case 'X':
2768 : 0 : pushOutput (eb);
2769 : 0 : break;
2770 : :
2771 : 0 : case 'Y':
2772 : 0 : processDefine (eb);
2773 : 0 : break;
2774 : :
2775 : 0 : case 'Z':
2776 : 0 : popOutput (eb);
2777 : 0 : break;
2778 : :
2779 : 6708 : case ':':
2780 : 6708 : ifNonNulThen (eb, (const unsigned int *) sym, _sym_high);
2781 : 6708 : (*eb).ini -= 1;
2782 : 6708 : break;
2783 : :
2784 : 0 : case '1':
2785 : 0 : M2Error_InternalError ((const char *) "incorrect format spec, expecting %1 rather than % spec 1", 56);
2786 : 0 : break;
2787 : :
2788 : 0 : case '2':
2789 : 0 : M2Error_InternalError ((const char *) "incorrect format spec, expecting %2 rather than % spec 2", 56);
2790 : 0 : break;
2791 : :
2792 : 0 : case '3':
2793 : 0 : M2Error_InternalError ((const char *) "incorrect format spec, expecting %3 rather than % spec 3", 56);
2794 : 0 : break;
2795 : :
2796 : 0 : case '4':
2797 : 0 : M2Error_InternalError ((const char *) "incorrect format spec, expecting %4 rather than % spec 4", 56);
2798 : 0 : break;
2799 : :
2800 : :
2801 : 0 : default:
2802 : 0 : InternalFormat ((*eb), (const char *) "expecting one of [akqtdnpsuCDEFGKNOPQRSTUWXYZ:<>%]", 50, 1742);
2803 : : break;
2804 : : }
2805 : 83911 : (*eb).ini += 1;
2806 : : }
2807 : 40678 : if (Debugging)
2808 : : {
2809 : : M2Printf_printf0 ((const char *) "finishing op\\n", 14);
2810 : : dump ((*eb));
2811 : : }
2812 : 40678 : }
2813 : :
2814 : :
2815 : : /*
2816 : : percenttoken := '%' (
2817 : : '1' % doOperand(1) %
2818 : : op
2819 : : | '2' % doOperand(2) %
2820 : : op
2821 : : | '3' % doOperand(3) %
2822 : : op
2823 : : | '4' % doOperand(4) %
2824 : : op
2825 : : )
2826 : : } =:
2827 : : */
2828 : :
2829 : 40678 : static void percenttoken (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high)
2830 : : {
2831 : 40678 : unsigned int sym[_sym_high+1];
2832 : :
2833 : : /* make a local copy of each unbounded array. */
2834 : 40678 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
2835 : :
2836 : 40678 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '%')
2837 : : {
2838 : 40678 : (*eb).ini += 1;
2839 : 40678 : switch (DynamicStrings_char ((*eb).in, (*eb).ini))
2840 : : {
2841 : 23965 : case '1':
2842 : 23965 : (*eb).ini += 1;
2843 : 23965 : op (eb, (const unsigned int *) sym, _sym_high, 0);
2844 : 23965 : break;
2845 : :
2846 : 12977 : case '2':
2847 : 12977 : (*eb).ini += 1;
2848 : 12977 : op (eb, (const unsigned int *) sym, _sym_high, 1);
2849 : 12977 : break;
2850 : :
2851 : 1992 : case '3':
2852 : 1992 : (*eb).ini += 1;
2853 : 1992 : op (eb, (const unsigned int *) sym, _sym_high, 2);
2854 : 1992 : break;
2855 : :
2856 : 228 : case '4':
2857 : 228 : (*eb).ini += 1;
2858 : 228 : op (eb, (const unsigned int *) sym, _sym_high, 3);
2859 : 228 : break;
2860 : :
2861 : :
2862 : 1516 : default:
2863 : 1516 : op (eb, (const unsigned int *) sym, _sym_high, 0);
2864 : 1516 : break;
2865 : : }
2866 : 40678 : if (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
2867 : : {
2868 : 0 : InternalFormat ((*eb), (const char *) "expecting to see }", 18, 1789);
2869 : : }
2870 : : }
2871 : 40678 : }
2872 : :
2873 : :
2874 : : /*
2875 : : changeColor - changes to color, c.
2876 : : */
2877 : :
2878 : 1260 : static void changeColor (M2MetaError_errorBlock *eb, M2MetaError_colorType c)
2879 : : {
2880 : 1260 : (*eb).currentCol = c;
2881 : 1152 : }
2882 : :
2883 : :
2884 : : /*
2885 : : shutdownColor - shutdown existing color if it exists.
2886 : : */
2887 : :
2888 : 102088 : static void shutdownColor (M2MetaError_errorBlock *eb)
2889 : : {
2890 : 102088 : if (((*eb).endCol != M2MetaError_unsetColor) && ((*eb).endCol != M2MetaError_noColor))
2891 : : {
2892 : 130950 : (*eb).out = colorEnd ((*eb).out);
2893 : 65475 : (*eb).endCol = M2MetaError_noColor;
2894 : : }
2895 : 102088 : }
2896 : :
2897 : :
2898 : : /*
2899 : : flushColor - flushes any outstanding color change.
2900 : : */
2901 : :
2902 : 1615091 : static void flushColor (M2MetaError_errorBlock *eb)
2903 : : {
2904 : 1615091 : if ((*eb).endCol != (*eb).currentCol)
2905 : : {
2906 : 73330 : shutdownColor (eb);
2907 : 73330 : if ((*eb).endCol != (*eb).currentCol)
2908 : : {
2909 : 75638 : emitColor (eb, (*eb).currentCol);
2910 : 37819 : (*eb).endCol = (*eb).currentCol;
2911 : : }
2912 : 73330 : if ((*eb).beginCol == M2MetaError_unsetColor)
2913 : : {
2914 : 22711 : (*eb).beginCol = (*eb).currentCol;
2915 : : }
2916 : : }
2917 : 1615091 : }
2918 : :
2919 : :
2920 : : /*
2921 : : emitColorGCC -
2922 : : */
2923 : :
2924 : 37819 : static void emitColorGCC (M2MetaError_errorBlock *eb, M2MetaError_colorType c)
2925 : : {
2926 : 37819 : switch (c)
2927 : : {
2928 : : case M2MetaError_unsetColor:
2929 : : break;
2930 : :
2931 : 380 : case M2MetaError_noColor:
2932 : 380 : (*eb).out = M2ColorString_endColor ((*eb).out);
2933 : 380 : break;
2934 : :
2935 : 0 : case M2MetaError_quoteColor:
2936 : 0 : (*eb).out = M2ColorString_quoteColor ((*eb).out);
2937 : 0 : break;
2938 : :
2939 : 0 : case M2MetaError_filenameColor:
2940 : 0 : (*eb).out = M2ColorString_filenameColor ((*eb).out);
2941 : 0 : break;
2942 : :
2943 : 10961 : case M2MetaError_errorColor:
2944 : 10961 : (*eb).out = M2ColorString_errorColor ((*eb).out);
2945 : 10961 : break;
2946 : :
2947 : 25280 : case M2MetaError_warningColor:
2948 : 25280 : (*eb).out = M2ColorString_warningColor ((*eb).out);
2949 : 25280 : break;
2950 : :
2951 : 46 : case M2MetaError_noteColor:
2952 : 46 : (*eb).out = M2ColorString_noteColor ((*eb).out);
2953 : 46 : break;
2954 : :
2955 : 1152 : case M2MetaError_keywordColor:
2956 : 1152 : (*eb).out = M2ColorString_locusColor ((*eb).out);
2957 : 1152 : break;
2958 : :
2959 : 0 : case M2MetaError_locusColor:
2960 : 0 : (*eb).out = M2ColorString_locusColor ((*eb).out);
2961 : 0 : break;
2962 : :
2963 : 0 : case M2MetaError_insertColor:
2964 : 0 : (*eb).out = M2ColorString_insertColor ((*eb).out);
2965 : 0 : break;
2966 : :
2967 : 0 : case M2MetaError_deleteColor:
2968 : 0 : (*eb).out = M2ColorString_deleteColor ((*eb).out);
2969 : 0 : break;
2970 : :
2971 : 0 : case M2MetaError_typeColor:
2972 : 0 : (*eb).out = M2ColorString_typeColor ((*eb).out);
2973 : 0 : break;
2974 : :
2975 : 0 : case M2MetaError_range1Color:
2976 : 0 : (*eb).out = M2ColorString_range1Color ((*eb).out);
2977 : 0 : break;
2978 : :
2979 : 0 : case M2MetaError_range2Color:
2980 : 0 : (*eb).out = M2ColorString_range2Color ((*eb).out);
2981 : 0 : break;
2982 : :
2983 : :
2984 : 0 : default:
2985 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2MetaError.def", 20, 1);
2986 : 0 : __builtin_unreachable ();
2987 : : }
2988 : 37819 : }
2989 : :
2990 : :
2991 : : /*
2992 : : emitColorTag -
2993 : : */
2994 : :
2995 : 0 : static void emitColorTag (M2MetaError_errorBlock *eb, M2MetaError_colorType c)
2996 : : {
2997 : 0 : DynamicStrings_String s;
2998 : :
2999 : 0 : switch (c)
3000 : : {
3001 : 0 : case M2MetaError_unsetColor:
3002 : 0 : s = DynamicStrings_InitString ((const char *) "<unset>", 7);
3003 : 0 : break;
3004 : :
3005 : 0 : case M2MetaError_noColor:
3006 : 0 : s = DynamicStrings_InitString ((const char *) "<nocol>", 7);
3007 : 0 : stop ();
3008 : 0 : break;
3009 : :
3010 : 0 : case M2MetaError_quoteColor:
3011 : 0 : s = DynamicStrings_InitString ((const char *) "<quote>", 7);
3012 : 0 : break;
3013 : :
3014 : 0 : case M2MetaError_filenameColor:
3015 : 0 : s = DynamicStrings_InitString ((const char *) "<filename>", 10);
3016 : 0 : break;
3017 : :
3018 : 0 : case M2MetaError_errorColor:
3019 : 0 : s = DynamicStrings_InitString ((const char *) "<error>", 7);
3020 : 0 : break;
3021 : :
3022 : 0 : case M2MetaError_warningColor:
3023 : 0 : s = DynamicStrings_InitString ((const char *) "<warn>", 6);
3024 : 0 : break;
3025 : :
3026 : 0 : case M2MetaError_noteColor:
3027 : 0 : s = DynamicStrings_InitString ((const char *) "<note>", 6);
3028 : 0 : break;
3029 : :
3030 : 0 : case M2MetaError_keywordColor:
3031 : 0 : s = DynamicStrings_InitString ((const char *) "<key>", 5);
3032 : 0 : break;
3033 : :
3034 : 0 : case M2MetaError_locusColor:
3035 : 0 : s = DynamicStrings_InitString ((const char *) "<locus>", 7);
3036 : 0 : break;
3037 : :
3038 : 0 : case M2MetaError_insertColor:
3039 : 0 : s = DynamicStrings_InitString ((const char *) "<insert>", 8);
3040 : 0 : break;
3041 : :
3042 : 0 : case M2MetaError_deleteColor:
3043 : 0 : s = DynamicStrings_InitString ((const char *) "<delete>", 8);
3044 : 0 : break;
3045 : :
3046 : 0 : case M2MetaError_typeColor:
3047 : 0 : s = DynamicStrings_InitString ((const char *) "<type>", 6);
3048 : 0 : break;
3049 : :
3050 : 0 : case M2MetaError_range1Color:
3051 : 0 : s = DynamicStrings_InitString ((const char *) "<range1>", 8);
3052 : 0 : break;
3053 : :
3054 : 0 : case M2MetaError_range2Color:
3055 : 0 : s = DynamicStrings_InitString ((const char *) "<range2>", 8);
3056 : 0 : break;
3057 : :
3058 : :
3059 : 0 : default:
3060 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2MetaError.def", 20, 1);
3061 : 0 : __builtin_unreachable ();
3062 : : }
3063 : 0 : (*eb).out = DynamicStrings_ConCat ((*eb).out, DynamicStrings_Mark (s));
3064 : 0 : }
3065 : :
3066 : :
3067 : : /*
3068 : : emitColor - adds the appropriate color string to the output string.
3069 : : */
3070 : :
3071 : 37819 : static void emitColor (M2MetaError_errorBlock *eb, M2MetaError_colorType c)
3072 : : {
3073 : 37819 : if (ColorDebug)
3074 : : {
3075 : : emitColorTag (eb, c);
3076 : : }
3077 : : else
3078 : : {
3079 : 37819 : emitColorGCC (eb, c);
3080 : : }
3081 : 0 : }
3082 : :
3083 : :
3084 : : /*
3085 : : openQuote -
3086 : : */
3087 : :
3088 : 28866 : static DynamicStrings_String openQuote (DynamicStrings_String s)
3089 : : {
3090 : 28866 : if (ColorDebug)
3091 : : {
3092 : : return DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "<openquote>", 11)));
3093 : : }
3094 : : else
3095 : : {
3096 : 28758 : return M2ColorString_quoteOpen (s);
3097 : : }
3098 : : /* static analysis guarentees a RETURN statement will be used before here. */
3099 : : __builtin_unreachable ();
3100 : : }
3101 : :
3102 : :
3103 : : /*
3104 : : closeQuote -
3105 : : */
3106 : :
3107 : 28866 : static DynamicStrings_String closeQuote (DynamicStrings_String s)
3108 : : {
3109 : 28866 : if (ColorDebug)
3110 : : {
3111 : : return DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "<closequote>", 12)));
3112 : : }
3113 : : else
3114 : : {
3115 : 28758 : return M2ColorString_quoteClose (s);
3116 : : }
3117 : : /* static analysis guarentees a RETURN statement will be used before here. */
3118 : : __builtin_unreachable ();
3119 : : }
3120 : :
3121 : :
3122 : : /*
3123 : : colorEnd -
3124 : : */
3125 : :
3126 : 65475 : static DynamicStrings_String colorEnd (DynamicStrings_String s)
3127 : : {
3128 : 65475 : stop ();
3129 : 65475 : if (ColorDebug)
3130 : : {
3131 : : return DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "<nocol>", 7)));
3132 : : }
3133 : : else
3134 : : {
3135 : 65475 : return M2ColorString_endColor (s);
3136 : : }
3137 : : /* static analysis guarentees a RETURN statement will be used before here. */
3138 : : __builtin_unreachable ();
3139 : : }
3140 : :
3141 : :
3142 : : /*
3143 : : copyChar - copies a character from in string to out string.
3144 : : */
3145 : :
3146 : 1471963 : static void copyChar (M2MetaError_errorBlock *eb)
3147 : : {
3148 : 1471963 : if ((*eb).ini < (*eb).len)
3149 : : {
3150 : 1471963 : flushColor (eb);
3151 : 1471963 : checkMe ();
3152 : 1471963 : (*eb).glyph = true;
3153 : 1471963 : (*eb).out = x ((*eb).out, DynamicStrings_ConCatChar ((*eb).out, DynamicStrings_char ((*eb).in, (*eb).ini)));
3154 : : }
3155 : 1471963 : }
3156 : :
3157 : :
3158 : : /*
3159 : : copyKeywordChar - copies a character from in string to out string
3160 : : it will convert the character to lower case if the
3161 : : -fm2-lower-case option was specified.
3162 : : */
3163 : :
3164 : 4998 : static void copyKeywordChar (M2MetaError_errorBlock *eb)
3165 : : {
3166 : 4998 : char ch;
3167 : :
3168 : 4998 : if ((*eb).ini < (*eb).len)
3169 : : {
3170 : 4998 : flushColor (eb);
3171 : 4998 : ch = DynamicStrings_char ((*eb).in, (*eb).ini);
3172 : 4998 : if (M2Options_LowerCaseKeywords)
3173 : : {
3174 : 0 : ch = StrCase_Lower (ch);
3175 : : }
3176 : 4998 : (*eb).glyph = true;
3177 : 4998 : (*eb).out = x ((*eb).out, DynamicStrings_ConCatChar ((*eb).out, ch));
3178 : : }
3179 : 4998 : }
3180 : :
3181 : :
3182 : : /*
3183 : : percent := '%' anych % copy anych %
3184 : : =:
3185 : : */
3186 : :
3187 : 222 : static void percent (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high)
3188 : : {
3189 : 222 : unsigned int sym[_sym_high+1];
3190 : :
3191 : : /* make a local copy of each unbounded array. */
3192 : 222 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
3193 : :
3194 : 222 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '%')
3195 : : {
3196 : 222 : (*eb).ini += 1;
3197 : 222 : if ((*eb).ini < (*eb).len)
3198 : : {
3199 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
3200 : 222 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '<')
3201 : : {
3202 : : /* %< is a quotation symbol. */
3203 : 108 : pushColor (eb);
3204 : 108 : (*eb).currentCol = M2MetaError_noColor;
3205 : 108 : flushColor (eb);
3206 : 108 : changeColor (eb, M2MetaError_quoteColor);
3207 : 108 : (*eb).endCol = M2MetaError_quoteColor; /* the openQuote will change the color. */
3208 : : /* OutGlyphS performs a flush and we are emitting the open quote glyph. */
3209 : 108 : OutGlyphS (eb, openQuote (DynamicStrings_InitString ((const char *) "", 0)));
3210 : : }
3211 : 114 : else if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '>')
3212 : : {
3213 : : /* avoid dangling else. */
3214 : 108 : OutGlyphS (eb, closeQuote (DynamicStrings_InitString ((const char *) "", 0)));
3215 : 108 : (*eb).endCol = M2MetaError_noColor; /* closeQuote also turns off color. */
3216 : 108 : popColor (eb); /* closeQuote also turns off color. */
3217 : : }
3218 : : else
3219 : : {
3220 : : /* avoid dangling else. */
3221 : 6 : copyChar (eb);
3222 : : }
3223 : : }
3224 : : }
3225 : 222 : }
3226 : :
3227 : :
3228 : : /*
3229 : : lbra := '{' [ '!' ] percenttoken '}' =:
3230 : : */
3231 : :
3232 : 40678 : static void lbra (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high)
3233 : : {
3234 : 40678 : unsigned int sym[_sym_high+1];
3235 : :
3236 : : /* make a local copy of each unbounded array. */
3237 : 40678 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
3238 : :
3239 : 40678 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '{')
3240 : : {
3241 : 40678 : (*eb).positive = true;
3242 : 40678 : (*eb).ini += 1;
3243 : 40678 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) == '!')
3244 : : {
3245 : 126 : (*eb).positive = false;
3246 : 126 : (*eb).ini += 1;
3247 : : }
3248 : 40678 : if ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '%')
3249 : : {
3250 : 0 : InternalFormat ((*eb), (const char *) "expecting to see %", 18, 2051);
3251 : : }
3252 : 40678 : percenttoken (eb, (const unsigned int *) sym, _sym_high);
3253 : 40678 : if (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
3254 : : {
3255 : 0 : InternalFormat ((*eb), (const char *) "expecting to see }", 18, 2056);
3256 : : }
3257 : : }
3258 : 40678 : }
3259 : :
3260 : :
3261 : : /*
3262 : : lbra := '{' [ '!' ] percenttoken '}' =:
3263 : : */
3264 : :
3265 : 0 : static void stop (void)
3266 : : {
3267 : 0 : }
3268 : :
3269 : :
3270 : : /*
3271 : : lbra := '{' [ '!' ] percenttoken '}' =:
3272 : : */
3273 : :
3274 : 0 : static void checkMe (void)
3275 : : {
3276 : 0 : }
3277 : :
3278 : :
3279 : : /*
3280 : : dumpErrorType -
3281 : : */
3282 : :
3283 : 0 : static void dumpErrorType (M2MetaError_errorType e)
3284 : : {
3285 : 0 : switch (e)
3286 : : {
3287 : 0 : case M2MetaError_none:
3288 : 0 : M2Printf_printf0 ((const char *) "none", 4);
3289 : 0 : break;
3290 : :
3291 : 0 : case M2MetaError_error:
3292 : 0 : M2Printf_printf0 ((const char *) "error", 5);
3293 : 0 : break;
3294 : :
3295 : 0 : case M2MetaError_warning:
3296 : 0 : M2Printf_printf0 ((const char *) "warning", 7);
3297 : 0 : break;
3298 : :
3299 : 0 : case M2MetaError_note:
3300 : 0 : M2Printf_printf0 ((const char *) "note", 4);
3301 : 0 : break;
3302 : :
3303 : 0 : case M2MetaError_chained:
3304 : 0 : M2Printf_printf0 ((const char *) "chained", 7);
3305 : 0 : break;
3306 : :
3307 : 0 : case M2MetaError_aborta:
3308 : 0 : M2Printf_printf0 ((const char *) "abort", 5);
3309 : 0 : break;
3310 : :
3311 : :
3312 : 0 : default:
3313 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2MetaError.def", 20, 1);
3314 : 0 : __builtin_unreachable ();
3315 : : }
3316 : 0 : }
3317 : :
3318 : :
3319 : : /*
3320 : : dumpColorType -
3321 : : */
3322 : :
3323 : 0 : static void dumpColorType (M2MetaError_colorType c)
3324 : : {
3325 : 0 : switch (c)
3326 : : {
3327 : 0 : case M2MetaError_unsetColor:
3328 : 0 : M2Printf_printf0 ((const char *) "unsetColor", 10);
3329 : 0 : break;
3330 : :
3331 : 0 : case M2MetaError_noColor:
3332 : 0 : M2Printf_printf0 ((const char *) "noColor", 7);
3333 : 0 : break;
3334 : :
3335 : 0 : case M2MetaError_quoteColor:
3336 : 0 : M2Printf_printf0 ((const char *) "quoteColor", 10);
3337 : 0 : break;
3338 : :
3339 : 0 : case M2MetaError_filenameColor:
3340 : 0 : M2Printf_printf0 ((const char *) "filenameColor", 13);
3341 : 0 : break;
3342 : :
3343 : 0 : case M2MetaError_errorColor:
3344 : 0 : M2Printf_printf0 ((const char *) "errorColor", 10);
3345 : 0 : break;
3346 : :
3347 : 0 : case M2MetaError_warningColor:
3348 : 0 : M2Printf_printf0 ((const char *) "warningColor", 12);
3349 : 0 : break;
3350 : :
3351 : 0 : case M2MetaError_noteColor:
3352 : 0 : M2Printf_printf0 ((const char *) "noteColor", 9);
3353 : 0 : break;
3354 : :
3355 : 0 : case M2MetaError_keywordColor:
3356 : 0 : M2Printf_printf0 ((const char *) "keywordColor", 12);
3357 : 0 : break;
3358 : :
3359 : 0 : case M2MetaError_locusColor:
3360 : 0 : M2Printf_printf0 ((const char *) "locusColor", 10);
3361 : 0 : break;
3362 : :
3363 : 0 : case M2MetaError_insertColor:
3364 : 0 : M2Printf_printf0 ((const char *) "insertColor", 11);
3365 : 0 : break;
3366 : :
3367 : 0 : case M2MetaError_deleteColor:
3368 : 0 : M2Printf_printf0 ((const char *) "deleteColor", 11);
3369 : 0 : break;
3370 : :
3371 : 0 : case M2MetaError_typeColor:
3372 : 0 : M2Printf_printf0 ((const char *) "typeColor", 9);
3373 : 0 : break;
3374 : :
3375 : 0 : case M2MetaError_range1Color:
3376 : 0 : M2Printf_printf0 ((const char *) "range1Color", 11);
3377 : 0 : break;
3378 : :
3379 : 0 : case M2MetaError_range2Color:
3380 : 0 : M2Printf_printf0 ((const char *) "range2Color", 11);
3381 : 0 : break;
3382 : :
3383 : :
3384 : 0 : default:
3385 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2MetaError.def", 20, 1);
3386 : 0 : __builtin_unreachable ();
3387 : : }
3388 : 0 : }
3389 : :
3390 : :
3391 : : /*
3392 : : dump -
3393 : :
3394 : : */
3395 : :
3396 : 0 : static void dump (M2MetaError_errorBlock eb)
3397 : : {
3398 : 0 : char ch;
3399 : 0 : unsigned int l;
3400 : 0 : int i;
3401 : :
3402 : 0 : l = DynamicStrings_Length (eb.out);
3403 : 0 : M2Printf_printf0 ((const char *) "\\n\\nerrorBlock\\n", 16);
3404 : 0 : M2Printf_printf0 ((const char *) "\\ntype = ", 14);
3405 : 0 : dumpErrorType (eb.type);
3406 : 0 : M2Printf_printf1 ((const char *) "\\nout = |%s|", 18, (const unsigned char *) &eb.out, (sizeof (eb.out)-1));
3407 : 0 : M2Printf_printf1 ((const char *) "\\nin = |%s|", 18, (const unsigned char *) &eb.in, (sizeof (eb.in)-1));
3408 : 0 : M2Printf_printf1 ((const char *) "\\nLength (out) = %d", 19, (const unsigned char *) &l, (sizeof (l)-1));
3409 : 0 : M2Printf_printf1 ((const char *) "\\nlen = %d", 16, (const unsigned char *) &eb.len, (sizeof (eb.len)-1));
3410 : 0 : M2Printf_printf1 ((const char *) "\\nhighplus1 = %d", 16, (const unsigned char *) &eb.highplus1, (sizeof (eb.highplus1)-1));
3411 : 0 : M2Printf_printf1 ((const char *) "\\nglyph = %d", 16, (const unsigned char *) &eb.glyph, (sizeof (eb.glyph)-1));
3412 : 0 : M2Printf_printf1 ((const char *) "\\nquotes = %d", 16, (const unsigned char *) &eb.quotes, (sizeof (eb.quotes)-1));
3413 : 0 : M2Printf_printf1 ((const char *) "\\npositive = %d", 16, (const unsigned char *) &eb.positive, (sizeof (eb.positive)-1));
3414 : 0 : M2Printf_printf0 ((const char *) "\\nbeginCol = ", 14);
3415 : 0 : dumpColorType (eb.beginCol);
3416 : 0 : M2Printf_printf0 ((const char *) "\\nendCol = ", 14);
3417 : 0 : dumpColorType (eb.endCol);
3418 : 0 : M2Printf_printf0 ((const char *) "\\ncurrentCol = ", 15);
3419 : 0 : dumpColorType (eb.currentCol);
3420 : 0 : M2Printf_printf1 ((const char *) "\\nini = %d", 17, (const unsigned char *) &eb.ini, (sizeof (eb.ini)-1));
3421 : 0 : if (eb.ini < eb.len)
3422 : : {
3423 : 0 : ch = DynamicStrings_char (eb.in, eb.ini);
3424 : 0 : M2Printf_printf1 ((const char *) "\\ncurrent char = %c", 19, (const unsigned char *) &ch, (sizeof (ch)-1));
3425 : 0 : M2Printf_printf1 ((const char *) "\\n%s\\n", 6, (const unsigned char *) &eb.in, (sizeof (eb.in)-1));
3426 : 0 : i = 0;
3427 : 0 : while (i < eb.ini)
3428 : : {
3429 : 0 : M2Printf_printf0 ((const char *) " ", 1);
3430 : 0 : i += 1;
3431 : : }
3432 : 0 : M2Printf_printf0 ((const char *) "^\\n", 3);
3433 : : }
3434 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
3435 : 0 : }
3436 : :
3437 : :
3438 : : /*
3439 : : ebnf := { percent
3440 : : | lbra
3441 : : | any % copy ch %
3442 : : }
3443 : : =:
3444 : : */
3445 : :
3446 : 21617 : static void ebnf (M2MetaError_errorBlock *eb, const unsigned int *sym_, unsigned int _sym_high)
3447 : : {
3448 : 21617 : M2MetaError_errorBlock nb;
3449 : 21617 : unsigned int sym[_sym_high+1];
3450 : :
3451 : : /* make a local copy of each unbounded array. */
3452 : 21617 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
3453 : :
3454 : 21617 : if (Debugging)
3455 : : {
3456 : : M2Printf_printf0 ((const char *) "top of ebnf\\n", 13);
3457 : : dump ((*eb));
3458 : : }
3459 : 1536796 : while ((*eb).ini < (*eb).len)
3460 : : {
3461 : 1520735 : if (Debugging)
3462 : : {
3463 : : M2Printf_printf0 ((const char *) "while loop ebnf\\n", 17);
3464 : : dump ((*eb));
3465 : : }
3466 : 1520735 : switch (DynamicStrings_char ((*eb).in, (*eb).ini))
3467 : : {
3468 : 0 : case '!':
3469 : 0 : (*eb).positive = ! (*eb).positive;
3470 : 0 : break;
3471 : :
3472 : 222 : case '%':
3473 : 222 : percent (eb, (const unsigned int *) sym, _sym_high);
3474 : 222 : break;
3475 : :
3476 : 40678 : case '{':
3477 : 40678 : push (&nb, (*eb));
3478 : 40678 : lbra (&nb, (const unsigned int *) sym, _sym_high);
3479 : 40678 : pop (eb, &nb);
3480 : 40678 : if (((*eb).ini < (*eb).len) && ((DynamicStrings_char ((*eb).in, (*eb).ini)) != '}'))
3481 : : {
3482 : 0 : InternalFormat ((*eb), (const char *) "expecting to see }", 18, 2187);
3483 : : }
3484 : : break;
3485 : :
3486 : 5556 : case '}':
3487 : 5556 : return;
3488 : 1474279 : break;
3489 : :
3490 : :
3491 : 1474279 : default:
3492 : 1474279 : if (((((IsWhite (DynamicStrings_char ((*eb).in, (*eb).ini))) && ((DynamicStrings_Length ((*eb).out)) > 0)) && (! (IsWhite (DynamicStrings_char ((*eb).out, -1))))) || (! (IsWhite (DynamicStrings_char ((*eb).in, (*eb).ini))))) && ((*eb).highplus1 > 0))
3493 : : {
3494 : 1471957 : (*eb).quotes = false; /* copying a normal character, don't quote the result. */
3495 : 1471957 : copyChar (eb); /* copying a normal character, don't quote the result. */
3496 : : }
3497 : : break;
3498 : : }
3499 : 1515179 : (*eb).ini += 1;
3500 : : }
3501 : 16061 : (*eb).currentCol = M2MetaError_noColor;
3502 : 16061 : flushColor (eb);
3503 : 16061 : if (Debugging)
3504 : : {
3505 : : M2Printf_printf0 ((const char *) "finishing ebnf\\n", 16);
3506 : : dump ((*eb));
3507 : : }
3508 : 21617 : }
3509 : :
3510 : :
3511 : : /*
3512 : : wrapErrors -
3513 : : */
3514 : :
3515 : 114 : static void wrapErrors (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned int *sym_, unsigned int _sym_high)
3516 : : {
3517 : 114 : M2MetaError_errorBlock eb;
3518 : 114 : char m1[_m1_high+1];
3519 : 114 : char m2[_m2_high+1];
3520 : 114 : unsigned int sym[_sym_high+1];
3521 : :
3522 : : /* make a local copy of each unbounded array. */
3523 : 114 : memcpy (m1, m1_, _m1_high+1);
3524 : 114 : memcpy (m2, m2_, _m2_high+1);
3525 : 114 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
3526 : :
3527 : 114 : initErrorBlock (&eb, DynamicStrings_InitString ((const char *) m1, _m1_high), (const unsigned int *) sym, _sym_high);
3528 : 114 : ebnf (&eb, (const unsigned int *) sym, _sym_high);
3529 : 114 : flushColor (&eb);
3530 : 114 : defaultError (&eb, tok);
3531 : 114 : lastRoot = eb.e;
3532 : 114 : M2Error_ErrorString (eb.e, DynamicStrings_Dup (eb.out));
3533 : 114 : killErrorBlock (&eb);
3534 : 114 : initErrorBlock (&eb, DynamicStrings_InitString ((const char *) m2, _m2_high), (const unsigned int *) sym, _sym_high);
3535 : 114 : eb.type = M2MetaError_chained;
3536 : 114 : ebnf (&eb, (const unsigned int *) sym, _sym_high);
3537 : 114 : flushColor (&eb);
3538 : 114 : defaultError (&eb, tok);
3539 : 114 : M2Error_ErrorString (eb.e, DynamicStrings_Dup (eb.out));
3540 : 114 : killErrorBlock (&eb);
3541 : 114 : }
3542 : :
3543 : :
3544 : : /*
3545 : : checkAbort - checks to see if the boolean flag seenAbort has been set,
3546 : : if so it flushes all existing errors and terminates.
3547 : : */
3548 : :
3549 : 2876 : static void checkAbort (void)
3550 : : {
3551 : 2876 : if (seenAbort)
3552 : : {
3553 : 82 : M2Error_FlushWarnings ();
3554 : 82 : M2Error_FlushErrors ();
3555 : : }
3556 : 2794 : }
3557 : :
3558 : :
3559 : : /*
3560 : : translate -
3561 : : */
3562 : :
3563 : 0 : static DynamicStrings_String translate (DynamicStrings_String m, DynamicStrings_String s, int *i, NameKey_Name name)
3564 : : {
3565 : 0 : int l;
3566 : 0 : char ch;
3567 : :
3568 : 0 : l = DynamicStrings_Length (m);
3569 : 0 : while (((*i) >= 0) && ((*i) < l))
3570 : : {
3571 : 0 : ch = DynamicStrings_char (m, (*i));
3572 : 0 : if ((ch == '%') && ((*i) < l))
3573 : : {
3574 : 0 : (*i) += 1;
3575 : 0 : ch = DynamicStrings_char (m, (*i));
3576 : 0 : (*i) += 1;
3577 : 0 : if (ch == 'a')
3578 : : {
3579 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%<", 2)));
3580 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
3581 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%>", 2)));
3582 : 0 : return s;
3583 : : }
3584 : 0 : s = DynamicStrings_ConCatChar (s, '%');
3585 : : }
3586 : 0 : s = DynamicStrings_ConCatChar (s, ch);
3587 : 0 : (*i) += 1;
3588 : : }
3589 : : return s;
3590 : : /* static analysis guarentees a RETURN statement will be used before here. */
3591 : : __builtin_unreachable ();
3592 : : }
3593 : :
3594 : :
3595 : : /*
3596 : : wrapString - return a string which has been formatted with the specifier codes.
3597 : : Color is disabled. The result string is returned.
3598 : : */
3599 : :
3600 : 12963 : static DynamicStrings_String wrapString (DynamicStrings_String m, const unsigned int *sym_, unsigned int _sym_high)
3601 : : {
3602 : 12963 : M2MetaError_errorBlock eb;
3603 : 12963 : DynamicStrings_String s;
3604 : 12963 : bool old;
3605 : 12963 : unsigned int sym[_sym_high+1];
3606 : :
3607 : : /* make a local copy of each unbounded array. */
3608 : 12963 : memcpy (sym, sym_, (_sym_high+1) * sizeof (unsigned int));
3609 : :
3610 : 25926 : old = M2ColorString_SetEnableColor (false);
3611 : 12963 : initErrorBlock (&eb, DynamicStrings_Dup (m), (const unsigned int *) sym, _sym_high);
3612 : 12963 : eb.useError = false;
3613 : 12963 : ebnf (&eb, (const unsigned int *) sym, _sym_high);
3614 : 12963 : flushColor (&eb);
3615 : 12963 : s = DynamicStrings_Dup (eb.out);
3616 : 12963 : killErrorBlock (&eb);
3617 : 12963 : old = M2ColorString_SetEnableColor (old);
3618 : 12963 : return s;
3619 : : /* static analysis guarentees a RETURN statement will be used before here. */
3620 : : __builtin_unreachable ();
3621 : 12963 : }
3622 : :
3623 : 0 : extern "C" void M2MetaError_MetaError0 (const char *m_, unsigned int _m_high)
3624 : : {
3625 : 0 : char m[_m_high+1];
3626 : :
3627 : : /* make a local copy of each unbounded array. */
3628 : 0 : memcpy (m, m_, _m_high+1);
3629 : :
3630 : 0 : M2MetaError_MetaErrorT0 (M2LexBuf_GetTokenNo (), (const char *) m, _m_high);
3631 : 0 : }
3632 : :
3633 : 394 : extern "C" void M2MetaError_MetaError1 (const char *m_, unsigned int _m_high, unsigned int s)
3634 : : {
3635 : 394 : char m[_m_high+1];
3636 : :
3637 : : /* make a local copy of each unbounded array. */
3638 : 394 : memcpy (m, m_, _m_high+1);
3639 : :
3640 : 394 : M2MetaError_MetaErrorT1 (M2LexBuf_GetTokenNo (), (const char *) m, _m_high, s);
3641 : 394 : }
3642 : :
3643 : 18 : extern "C" void M2MetaError_MetaError2 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2)
3644 : : {
3645 : 18 : char m[_m_high+1];
3646 : :
3647 : : /* make a local copy of each unbounded array. */
3648 : 18 : memcpy (m, m_, _m_high+1);
3649 : :
3650 : 18 : M2MetaError_MetaErrorT2 (M2LexBuf_GetTokenNo (), (const char *) m, _m_high, s1, s2);
3651 : 18 : }
3652 : :
3653 : 0 : extern "C" void M2MetaError_MetaError3 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3)
3654 : : {
3655 : 0 : char m[_m_high+1];
3656 : :
3657 : : /* make a local copy of each unbounded array. */
3658 : 0 : memcpy (m, m_, _m_high+1);
3659 : :
3660 : 0 : M2MetaError_MetaErrorT3 (M2LexBuf_GetTokenNo (), (const char *) m, _m_high, s1, s2, s3);
3661 : 0 : }
3662 : :
3663 : 0 : extern "C" void M2MetaError_MetaError4 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4)
3664 : : {
3665 : 0 : char m[_m_high+1];
3666 : :
3667 : : /* make a local copy of each unbounded array. */
3668 : 0 : memcpy (m, m_, _m_high+1);
3669 : :
3670 : 0 : M2MetaError_MetaErrorT4 (M2LexBuf_GetTokenNo (), (const char *) m, _m_high, s1, s2, s3, s4);
3671 : 0 : }
3672 : :
3673 : :
3674 : : /*
3675 : : wrapErrors -
3676 : : */
3677 : :
3678 : 18 : extern "C" void M2MetaError_MetaErrors1 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s)
3679 : : {
3680 : 18 : char m1[_m1_high+1];
3681 : 18 : char m2[_m2_high+1];
3682 : :
3683 : : /* make a local copy of each unbounded array. */
3684 : 18 : memcpy (m1, m1_, _m1_high+1);
3685 : 18 : memcpy (m2, m2_, _m2_high+1);
3686 : :
3687 : 18 : M2MetaError_MetaErrorsT1 (M2LexBuf_GetTokenNo (), (const char *) m1, _m1_high, (const char *) m2, _m2_high, s);
3688 : 18 : }
3689 : :
3690 : :
3691 : : /*
3692 : : wrapErrors -
3693 : : */
3694 : :
3695 : 6 : extern "C" void M2MetaError_MetaErrors2 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2)
3696 : : {
3697 : 6 : char m1[_m1_high+1];
3698 : 6 : char m2[_m2_high+1];
3699 : :
3700 : : /* make a local copy of each unbounded array. */
3701 : 6 : memcpy (m1, m1_, _m1_high+1);
3702 : 6 : memcpy (m2, m2_, _m2_high+1);
3703 : :
3704 : 6 : M2MetaError_MetaErrorsT2 (M2LexBuf_GetTokenNo (), (const char *) m1, _m1_high, (const char *) m2, _m2_high, s1, s2);
3705 : 6 : }
3706 : :
3707 : :
3708 : : /*
3709 : : wrapErrors -
3710 : : */
3711 : :
3712 : 0 : extern "C" void M2MetaError_MetaErrors3 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3)
3713 : : {
3714 : 0 : char m1[_m1_high+1];
3715 : 0 : char m2[_m2_high+1];
3716 : :
3717 : : /* make a local copy of each unbounded array. */
3718 : 0 : memcpy (m1, m1_, _m1_high+1);
3719 : 0 : memcpy (m2, m2_, _m2_high+1);
3720 : :
3721 : 0 : M2MetaError_MetaErrorsT3 (M2LexBuf_GetTokenNo (), (const char *) m1, _m1_high, (const char *) m2, _m2_high, s1, s2, s3);
3722 : 0 : }
3723 : :
3724 : :
3725 : : /*
3726 : : wrapErrors -
3727 : : */
3728 : :
3729 : 0 : extern "C" void M2MetaError_MetaErrors4 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4)
3730 : : {
3731 : 0 : char m1[_m1_high+1];
3732 : 0 : char m2[_m2_high+1];
3733 : :
3734 : : /* make a local copy of each unbounded array. */
3735 : 0 : memcpy (m1, m1_, _m1_high+1);
3736 : 0 : memcpy (m2, m2_, _m2_high+1);
3737 : :
3738 : 0 : M2MetaError_MetaErrorsT4 (M2LexBuf_GetTokenNo (), (const char *) m1, _m1_high, (const char *) m2, _m2_high, s1, s2, s3, s4);
3739 : 0 : }
3740 : :
3741 : 58 : extern "C" void M2MetaError_MetaErrorT0 (unsigned int tok, const char *m_, unsigned int _m_high)
3742 : : {
3743 : 58 : char m[_m_high+1];
3744 : :
3745 : : /* make a local copy of each unbounded array. */
3746 : 58 : memcpy (m, m_, _m_high+1);
3747 : :
3748 : 58 : M2MetaError_MetaErrorStringT0 (tok, DynamicStrings_InitString ((const char *) m, _m_high));
3749 : 58 : }
3750 : :
3751 : 1104 : extern "C" void M2MetaError_MetaErrorT1 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s)
3752 : : {
3753 : 1104 : char m[_m_high+1];
3754 : :
3755 : : /* make a local copy of each unbounded array. */
3756 : 1104 : memcpy (m, m_, _m_high+1);
3757 : :
3758 : 1104 : M2MetaError_MetaErrorStringT1 (tok, DynamicStrings_InitString ((const char *) m, _m_high), s);
3759 : 1104 : }
3760 : :
3761 : 511 : extern "C" void M2MetaError_MetaErrorT2 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2)
3762 : : {
3763 : 511 : char m[_m_high+1];
3764 : :
3765 : : /* make a local copy of each unbounded array. */
3766 : 511 : memcpy (m, m_, _m_high+1);
3767 : :
3768 : 511 : M2MetaError_MetaErrorStringT2 (tok, DynamicStrings_InitString ((const char *) m, _m_high), s1, s2);
3769 : 511 : }
3770 : :
3771 : 60 : extern "C" void M2MetaError_MetaErrorT3 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3)
3772 : : {
3773 : 60 : char m[_m_high+1];
3774 : :
3775 : : /* make a local copy of each unbounded array. */
3776 : 60 : memcpy (m, m_, _m_high+1);
3777 : :
3778 : 60 : M2MetaError_MetaErrorStringT3 (tok, DynamicStrings_InitString ((const char *) m, _m_high), s1, s2, s3);
3779 : 60 : }
3780 : :
3781 : 12 : extern "C" void M2MetaError_MetaErrorT4 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4)
3782 : : {
3783 : 12 : char m[_m_high+1];
3784 : :
3785 : : /* make a local copy of each unbounded array. */
3786 : 12 : memcpy (m, m_, _m_high+1);
3787 : :
3788 : 12 : M2MetaError_MetaErrorStringT4 (tok, DynamicStrings_InitString ((const char *) m, _m_high), s1, s2, s3, s4);
3789 : 12 : }
3790 : :
3791 : :
3792 : : /*
3793 : : wrapErrors -
3794 : : */
3795 : :
3796 : 18 : extern "C" void M2MetaError_MetaErrorsT1 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s)
3797 : : {
3798 : 18 : typedef struct MetaErrorsT1__T4_a MetaErrorsT1__T4;
3799 : :
3800 : 18 : struct MetaErrorsT1__T4_a { unsigned int array[0+1]; };
3801 : 18 : MetaErrorsT1__T4 sym;
3802 : 18 : char m1[_m1_high+1];
3803 : 18 : char m2[_m2_high+1];
3804 : :
3805 : : /* make a local copy of each unbounded array. */
3806 : 18 : memcpy (m1, m1_, _m1_high+1);
3807 : 18 : memcpy (m2, m2_, _m2_high+1);
3808 : :
3809 : 18 : sym.array[0] = s;
3810 : 18 : wrapErrors (tok, (const char *) m1, _m1_high, (const char *) m2, _m2_high, (const unsigned int *) &sym.array[0], 0);
3811 : 18 : }
3812 : :
3813 : :
3814 : : /*
3815 : : wrapErrors -
3816 : : */
3817 : :
3818 : 96 : extern "C" void M2MetaError_MetaErrorsT2 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2)
3819 : : {
3820 : 96 : typedef struct MetaErrorsT2__T5_a MetaErrorsT2__T5;
3821 : :
3822 : 96 : struct MetaErrorsT2__T5_a { unsigned int array[1+1]; };
3823 : 96 : MetaErrorsT2__T5 sym;
3824 : 96 : char m1[_m1_high+1];
3825 : 96 : char m2[_m2_high+1];
3826 : :
3827 : : /* make a local copy of each unbounded array. */
3828 : 96 : memcpy (m1, m1_, _m1_high+1);
3829 : 96 : memcpy (m2, m2_, _m2_high+1);
3830 : :
3831 : 96 : sym.array[0] = s1;
3832 : 96 : sym.array[1] = s2;
3833 : 96 : wrapErrors (tok, (const char *) m1, _m1_high, (const char *) m2, _m2_high, (const unsigned int *) &sym.array[0], 1);
3834 : 96 : }
3835 : :
3836 : :
3837 : : /*
3838 : : wrapErrors -
3839 : : */
3840 : :
3841 : 0 : extern "C" void M2MetaError_MetaErrorsT3 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3)
3842 : : {
3843 : 0 : typedef struct MetaErrorsT3__T6_a MetaErrorsT3__T6;
3844 : :
3845 : 0 : struct MetaErrorsT3__T6_a { unsigned int array[2+1]; };
3846 : 0 : MetaErrorsT3__T6 sym;
3847 : 0 : char m1[_m1_high+1];
3848 : 0 : char m2[_m2_high+1];
3849 : :
3850 : : /* make a local copy of each unbounded array. */
3851 : 0 : memcpy (m1, m1_, _m1_high+1);
3852 : 0 : memcpy (m2, m2_, _m2_high+1);
3853 : :
3854 : 0 : sym.array[0] = s1;
3855 : 0 : sym.array[1] = s2;
3856 : 0 : sym.array[2] = s3;
3857 : 0 : wrapErrors (tok, (const char *) m1, _m1_high, (const char *) m2, _m2_high, (const unsigned int *) &sym.array[0], 2);
3858 : 0 : }
3859 : :
3860 : :
3861 : : /*
3862 : : wrapErrors -
3863 : : */
3864 : :
3865 : 0 : extern "C" void M2MetaError_MetaErrorsT4 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4)
3866 : : {
3867 : 0 : typedef struct MetaErrorsT4__T7_a MetaErrorsT4__T7;
3868 : :
3869 : 0 : struct MetaErrorsT4__T7_a { unsigned int array[3+1]; };
3870 : 0 : MetaErrorsT4__T7 sym;
3871 : 0 : char m1[_m1_high+1];
3872 : 0 : char m2[_m2_high+1];
3873 : :
3874 : : /* make a local copy of each unbounded array. */
3875 : 0 : memcpy (m1, m1_, _m1_high+1);
3876 : 0 : memcpy (m2, m2_, _m2_high+1);
3877 : :
3878 : 0 : sym.array[0] = s1;
3879 : 0 : sym.array[1] = s2;
3880 : 0 : sym.array[2] = s3;
3881 : 0 : sym.array[3] = s4;
3882 : 0 : wrapErrors (tok, (const char *) m1, _m1_high, (const char *) m2, _m2_high, (const unsigned int *) &sym.array[0], 3);
3883 : 0 : }
3884 : :
3885 : :
3886 : : /*
3887 : : wrapErrors -
3888 : : */
3889 : :
3890 : 0 : extern "C" void M2MetaError_MetaErrorString0 (DynamicStrings_String m)
3891 : : {
3892 : 0 : M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), m);
3893 : 0 : }
3894 : :
3895 : :
3896 : : /*
3897 : : wrapErrors -
3898 : : */
3899 : :
3900 : 0 : extern "C" void M2MetaError_MetaErrorString1 (DynamicStrings_String m, unsigned int s)
3901 : : {
3902 : 0 : M2MetaError_MetaErrorStringT1 (M2LexBuf_GetTokenNo (), m, s);
3903 : 0 : }
3904 : :
3905 : :
3906 : : /*
3907 : : wrapErrors -
3908 : : */
3909 : :
3910 : 0 : extern "C" void M2MetaError_MetaErrorString2 (DynamicStrings_String m, unsigned int s1, unsigned int s2)
3911 : : {
3912 : 0 : M2MetaError_MetaErrorStringT2 (M2LexBuf_GetTokenNo (), m, s1, s2);
3913 : 0 : }
3914 : :
3915 : :
3916 : : /*
3917 : : wrapErrors -
3918 : : */
3919 : :
3920 : 120 : extern "C" void M2MetaError_MetaErrorString3 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3)
3921 : : {
3922 : 120 : M2MetaError_MetaErrorStringT3 (M2LexBuf_GetTokenNo (), m, s1, s2, s3);
3923 : 120 : }
3924 : :
3925 : :
3926 : : /*
3927 : : wrapErrors -
3928 : : */
3929 : :
3930 : 0 : extern "C" void M2MetaError_MetaErrorString4 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4)
3931 : : {
3932 : 0 : M2MetaError_MetaErrorStringT4 (M2LexBuf_GetTokenNo (), m, s1, s2, s3, s4);
3933 : 0 : }
3934 : :
3935 : 532 : extern "C" void M2MetaError_MetaErrorStringT0 (unsigned int tok, DynamicStrings_String m)
3936 : : {
3937 : 532 : typedef struct MetaErrorStringT0__T8_a MetaErrorStringT0__T8;
3938 : :
3939 : 532 : struct MetaErrorStringT0__T8_a { unsigned int array[0+1]; };
3940 : 532 : M2MetaError_errorBlock eb;
3941 : 532 : MetaErrorStringT0__T8 sym;
3942 : :
3943 : 532 : sym.array[0] = SymbolTable_NulSym;
3944 : 532 : initErrorBlock (&eb, m, (const unsigned int *) &sym.array[0], 0);
3945 : 532 : ebnf (&eb, (const unsigned int *) &sym.array[0], 0);
3946 : 532 : flushColor (&eb);
3947 : 532 : defaultError (&eb, tok);
3948 : 532 : M2Error_ErrorString (eb.e, DynamicStrings_Dup (eb.out));
3949 : 532 : killErrorBlock (&eb);
3950 : 532 : checkAbort ();
3951 : 520 : }
3952 : :
3953 : 1562 : extern "C" void M2MetaError_MetaErrorStringT1 (unsigned int tok, DynamicStrings_String m, unsigned int s)
3954 : : {
3955 : 1562 : typedef struct MetaErrorStringT1__T9_a MetaErrorStringT1__T9;
3956 : :
3957 : 1562 : struct MetaErrorStringT1__T9_a { unsigned int array[0+1]; };
3958 : 1562 : M2MetaError_errorBlock eb;
3959 : 1562 : MetaErrorStringT1__T9 sym;
3960 : :
3961 : 1562 : sym.array[0] = s;
3962 : 1562 : initErrorBlock (&eb, m, (const unsigned int *) &sym.array[0], 0);
3963 : 1562 : ebnf (&eb, (const unsigned int *) &sym.array[0], 0);
3964 : 1562 : flushColor (&eb);
3965 : 1562 : defaultError (&eb, tok);
3966 : 1562 : M2Error_ErrorString (eb.e, DynamicStrings_Dup (eb.out));
3967 : 1562 : killErrorBlock (&eb);
3968 : 1562 : checkAbort ();
3969 : 1492 : }
3970 : :
3971 : 590 : extern "C" void M2MetaError_MetaErrorStringT2 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2)
3972 : : {
3973 : 590 : typedef struct MetaErrorStringT2__T10_a MetaErrorStringT2__T10;
3974 : :
3975 : 590 : struct MetaErrorStringT2__T10_a { unsigned int array[1+1]; };
3976 : 590 : M2MetaError_errorBlock eb;
3977 : 590 : MetaErrorStringT2__T10 sym;
3978 : :
3979 : 590 : sym.array[0] = s1;
3980 : 590 : sym.array[1] = s2;
3981 : 590 : initErrorBlock (&eb, m, (const unsigned int *) &sym.array[0], 1);
3982 : 590 : ebnf (&eb, (const unsigned int *) &sym.array[0], 1);
3983 : 590 : flushColor (&eb);
3984 : 590 : defaultError (&eb, tok);
3985 : 590 : M2Error_ErrorString (eb.e, DynamicStrings_Dup (eb.out));
3986 : 590 : killErrorBlock (&eb);
3987 : 590 : checkAbort ();
3988 : 590 : }
3989 : :
3990 : 180 : extern "C" void M2MetaError_MetaErrorStringT3 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3)
3991 : : {
3992 : 180 : typedef struct MetaErrorStringT3__T11_a MetaErrorStringT3__T11;
3993 : :
3994 : 180 : struct MetaErrorStringT3__T11_a { unsigned int array[2+1]; };
3995 : 180 : M2MetaError_errorBlock eb;
3996 : 180 : MetaErrorStringT3__T11 sym;
3997 : :
3998 : 180 : sym.array[0] = s1;
3999 : 180 : sym.array[1] = s2;
4000 : 180 : sym.array[2] = s3;
4001 : 180 : initErrorBlock (&eb, m, (const unsigned int *) &sym.array[0], 2);
4002 : 180 : eb.highplus1 = 2+1;
4003 : 180 : ebnf (&eb, (const unsigned int *) &sym.array[0], 2);
4004 : 180 : flushColor (&eb);
4005 : 180 : defaultError (&eb, tok);
4006 : 180 : M2Error_ErrorString (eb.e, DynamicStrings_Dup (eb.out));
4007 : 180 : killErrorBlock (&eb);
4008 : 180 : checkAbort ();
4009 : 180 : }
4010 : :
4011 : 12 : extern "C" void M2MetaError_MetaErrorStringT4 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4)
4012 : : {
4013 : 12 : typedef struct MetaErrorStringT4__T12_a MetaErrorStringT4__T12;
4014 : :
4015 : 12 : struct MetaErrorStringT4__T12_a { unsigned int array[3+1]; };
4016 : 12 : M2MetaError_errorBlock eb;
4017 : 12 : MetaErrorStringT4__T12 sym;
4018 : :
4019 : 12 : sym.array[0] = s1;
4020 : 12 : sym.array[1] = s2;
4021 : 12 : sym.array[2] = s3;
4022 : 12 : sym.array[3] = s4;
4023 : 12 : initErrorBlock (&eb, m, (const unsigned int *) &sym.array[0], 3);
4024 : 12 : ebnf (&eb, (const unsigned int *) &sym.array[0], 3);
4025 : 12 : flushColor (&eb);
4026 : 12 : defaultError (&eb, tok);
4027 : 12 : M2Error_ErrorString (eb.e, DynamicStrings_Dup (eb.out));
4028 : 12 : killErrorBlock (&eb);
4029 : 12 : checkAbort ();
4030 : 12 : }
4031 : :
4032 : :
4033 : : /*
4034 : : MetaErrorN1 -
4035 : : */
4036 : :
4037 : 0 : extern "C" void M2MetaError_MetaErrorN1 (const char *m_, unsigned int _m_high, NameKey_Name n)
4038 : : {
4039 : 0 : char m[_m_high+1];
4040 : :
4041 : : /* make a local copy of each unbounded array. */
4042 : 0 : memcpy (m, m_, _m_high+1);
4043 : :
4044 : 0 : M2MetaError_MetaErrorNT1 (M2LexBuf_GetTokenNo (), (const char *) m, _m_high, n);
4045 : 0 : }
4046 : :
4047 : :
4048 : : /*
4049 : : MetaErrorN2 -
4050 : : */
4051 : :
4052 : 0 : extern "C" void M2MetaError_MetaErrorN2 (const char *m_, unsigned int _m_high, NameKey_Name n1, NameKey_Name n2)
4053 : : {
4054 : 0 : char m[_m_high+1];
4055 : :
4056 : : /* make a local copy of each unbounded array. */
4057 : 0 : memcpy (m, m_, _m_high+1);
4058 : :
4059 : 0 : M2MetaError_MetaErrorNT2 (M2LexBuf_GetTokenNo (), (const char *) m, _m_high, n1, n2);
4060 : 0 : }
4061 : :
4062 : :
4063 : : /*
4064 : : MetaErrorNT0 - generate an error message at tok using format.
4065 : : */
4066 : :
4067 : 0 : extern "C" void M2MetaError_MetaErrorNT0 (unsigned int tok, const char *format_, unsigned int _format_high)
4068 : : {
4069 : 0 : char format[_format_high+1];
4070 : :
4071 : : /* make a local copy of each unbounded array. */
4072 : 0 : memcpy (format, format_, _format_high+1);
4073 : :
4074 : 0 : M2MetaError_MetaErrorStringT0 (tok, DynamicStrings_InitString ((const char *) format, _format_high));
4075 : 0 : }
4076 : :
4077 : :
4078 : : /*
4079 : : MetaErrorNT1 - generate an error message at tok using format and name.
4080 : : The format should contain %a for name substitution.
4081 : : */
4082 : :
4083 : 0 : extern "C" void M2MetaError_MetaErrorNT1 (unsigned int tok, const char *format_, unsigned int _format_high, NameKey_Name name)
4084 : : {
4085 : 0 : int i;
4086 : 0 : DynamicStrings_String s;
4087 : 0 : DynamicStrings_String fmt;
4088 : 0 : char format[_format_high+1];
4089 : :
4090 : : /* make a local copy of each unbounded array. */
4091 : 0 : memcpy (format, format_, _format_high+1);
4092 : :
4093 : 0 : i = 0;
4094 : 0 : fmt = DynamicStrings_InitString ((const char *) format, _format_high);
4095 : 0 : s = DynamicStrings_InitString ((const char *) "", 0);
4096 : 0 : s = translate (fmt, s, &i, name);
4097 : 0 : M2MetaError_MetaErrorStringT0 (tok, s);
4098 : 0 : fmt = DynamicStrings_KillString (fmt);
4099 : 0 : }
4100 : :
4101 : 0 : extern "C" void M2MetaError_MetaErrorNT2 (unsigned int tok, const char *format_, unsigned int _format_high, NameKey_Name name1, NameKey_Name name2)
4102 : : {
4103 : 0 : int i;
4104 : 0 : DynamicStrings_String s;
4105 : 0 : DynamicStrings_String fmt;
4106 : 0 : char format[_format_high+1];
4107 : :
4108 : : /* make a local copy of each unbounded array. */
4109 : 0 : memcpy (format, format_, _format_high+1);
4110 : :
4111 : : /*
4112 : : MetaErrorNT1 - generate an error message at tok using format, name1
4113 : : and name2. The format should contain two occurances of %a
4114 : : for name substitution.
4115 : : */
4116 : 0 : i = 0;
4117 : 0 : fmt = DynamicStrings_InitString ((const char *) format, _format_high);
4118 : 0 : s = DynamicStrings_InitString ((const char *) "", 0);
4119 : 0 : s = translate (fmt, s, &i, name1);
4120 : 0 : s = translate (fmt, s, &i, name2);
4121 : 0 : M2MetaError_MetaErrorStringT0 (tok, s);
4122 : 0 : fmt = DynamicStrings_KillString (fmt);
4123 : 0 : }
4124 : :
4125 : :
4126 : : /*
4127 : : wrapString - return a string which has been formatted with the specifier codes.
4128 : : Color is disabled. The result string is returned.
4129 : : */
4130 : :
4131 : 18 : extern "C" DynamicStrings_String M2MetaError_MetaString0 (DynamicStrings_String m)
4132 : : {
4133 : 18 : typedef struct MetaString0__T13_a MetaString0__T13;
4134 : :
4135 : 18 : struct MetaString0__T13_a { unsigned int array[0+1]; };
4136 : 18 : MetaString0__T13 sym;
4137 : :
4138 : 18 : sym.array[0] = SymbolTable_NulSym;
4139 : 18 : return wrapString (m, (const unsigned int *) &sym.array[0], 0);
4140 : : /* static analysis guarentees a RETURN statement will be used before here. */
4141 : : __builtin_unreachable ();
4142 : : }
4143 : :
4144 : :
4145 : : /*
4146 : : wrapString - return a string which has been formatted with the specifier codes.
4147 : : Color is disabled. The result string is returned.
4148 : : */
4149 : :
4150 : 66 : extern "C" DynamicStrings_String M2MetaError_MetaString1 (DynamicStrings_String m, unsigned int s)
4151 : : {
4152 : 66 : typedef struct MetaString1__T14_a MetaString1__T14;
4153 : :
4154 : 66 : struct MetaString1__T14_a { unsigned int array[0+1]; };
4155 : 66 : MetaString1__T14 sym;
4156 : :
4157 : 66 : sym.array[0] = s;
4158 : 66 : return wrapString (m, (const unsigned int *) &sym.array[0], 0);
4159 : : /* static analysis guarentees a RETURN statement will be used before here. */
4160 : : __builtin_unreachable ();
4161 : : }
4162 : :
4163 : :
4164 : : /*
4165 : : wrapString - return a string which has been formatted with the specifier codes.
4166 : : Color is disabled. The result string is returned.
4167 : : */
4168 : :
4169 : 588 : extern "C" DynamicStrings_String M2MetaError_MetaString2 (DynamicStrings_String m, unsigned int s1, unsigned int s2)
4170 : : {
4171 : 588 : typedef struct MetaString2__T15_a MetaString2__T15;
4172 : :
4173 : 588 : struct MetaString2__T15_a { unsigned int array[1+1]; };
4174 : 588 : MetaString2__T15 sym;
4175 : :
4176 : 588 : sym.array[0] = s1;
4177 : 588 : sym.array[1] = s2;
4178 : 588 : return wrapString (m, (const unsigned int *) &sym.array[0], 1);
4179 : : /* static analysis guarentees a RETURN statement will be used before here. */
4180 : : __builtin_unreachable ();
4181 : : }
4182 : :
4183 : :
4184 : : /*
4185 : : wrapString - return a string which has been formatted with the specifier codes.
4186 : : Color is disabled. The result string is returned.
4187 : : */
4188 : :
4189 : 12183 : extern "C" DynamicStrings_String M2MetaError_MetaString3 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3)
4190 : : {
4191 : 12183 : typedef struct MetaString3__T16_a MetaString3__T16;
4192 : :
4193 : 12183 : struct MetaString3__T16_a { unsigned int array[2+1]; };
4194 : 12183 : MetaString3__T16 sym;
4195 : :
4196 : 12183 : sym.array[0] = s1;
4197 : 12183 : sym.array[1] = s2;
4198 : 12183 : sym.array[2] = s3;
4199 : 12183 : return wrapString (m, (const unsigned int *) &sym.array[0], 2);
4200 : : /* static analysis guarentees a RETURN statement will be used before here. */
4201 : : __builtin_unreachable ();
4202 : : }
4203 : :
4204 : :
4205 : : /*
4206 : : wrapString - return a string which has been formatted with the specifier codes.
4207 : : Color is disabled. The result string is returned.
4208 : : */
4209 : :
4210 : 108 : extern "C" DynamicStrings_String M2MetaError_MetaString4 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4)
4211 : : {
4212 : 108 : typedef struct MetaString4__T17_a MetaString4__T17;
4213 : :
4214 : 108 : struct MetaString4__T17_a { unsigned int array[3+1]; };
4215 : 108 : MetaString4__T17 sym;
4216 : :
4217 : 108 : sym.array[0] = s1;
4218 : 108 : sym.array[1] = s2;
4219 : 108 : sym.array[2] = s3;
4220 : 108 : sym.array[3] = s4;
4221 : 108 : return wrapString (m, (const unsigned int *) &sym.array[0], 3);
4222 : : /* static analysis guarentees a RETURN statement will be used before here. */
4223 : : __builtin_unreachable ();
4224 : : }
4225 : :
4226 : :
4227 : : /*
4228 : : MetaErrorDecl - if sym is a variable or parameter then generate a
4229 : : declaration error or warning message. If error is
4230 : : FALSE then a warning is issued.
4231 : : */
4232 : :
4233 : 264 : extern "C" void M2MetaError_MetaErrorDecl (unsigned int sym, bool error)
4234 : : {
4235 : 264 : if ((sym != SymbolTable_NulSym) && (SymbolTable_IsVar (sym)))
4236 : : {
4237 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
4238 : 222 : if (error)
4239 : : {
4240 : 222 : if (SymbolTable_IsVarAParam (sym))
4241 : : {
4242 : 0 : M2MetaError_MetaErrorT1 (SymbolTable_GetVarDeclFullTok (sym), (const char *) "parameter declaration for {%1ad}", 32, sym);
4243 : : }
4244 : : else
4245 : : {
4246 : 222 : M2MetaError_MetaErrorT1 (SymbolTable_GetVarDeclFullTok (sym), (const char *) "variable declaration for {%1ad}", 31, sym);
4247 : : }
4248 : : }
4249 : : else
4250 : : {
4251 : 0 : if (SymbolTable_IsVarAParam (sym))
4252 : : {
4253 : 0 : M2MetaError_MetaErrorT1 (SymbolTable_GetVarDeclFullTok (sym), (const char *) "parameter declaration for {%1Wad}", 33, sym);
4254 : : }
4255 : : else
4256 : : {
4257 : 0 : M2MetaError_MetaErrorT1 (SymbolTable_GetVarDeclFullTok (sym), (const char *) "variable declaration for {%1Wad}", 32, sym);
4258 : : }
4259 : : }
4260 : : }
4261 : 264 : }
4262 : :
4263 : 14720 : extern "C" void _M2_M2MetaError_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
4264 : : {
4265 : 14720 : lastRoot = static_cast<M2Error_Error> (NULL);
4266 : 14720 : lastColor = M2MetaError_noColor;
4267 : 14720 : seenAbort = false;
4268 : 14720 : outputStack = Indexing_InitIndex (1);
4269 : 14720 : dictionary = Indexing_InitIndex (1);
4270 : 14720 : freeEntry = NULL;
4271 : 14720 : }
4272 : :
4273 : 0 : extern "C" void _M2_M2MetaError_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
4274 : : {
4275 : 0 : }
|