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