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