Skip to content

Commit cd530f1

Browse files
committed
number each error or warning printed by the parser
1 parent 4dc506d commit cd530f1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

include/express/error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ typedef struct Error_ {
6666
bool enabled;
6767
Severity severity;
6868
char * message;
69+
int serial; /* used to give each type of error a unique identifier */
6970
} * Error;
7071

7172
typedef struct Error_Warning_ {

src/express/error.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ va_dcl {
262262
( what != ERROR_subordinate_failed ) &&
263263
what->enabled ) {
264264
if( what->severity >= SEVERITY_ERROR ) {
265-
fprintf( error_file, "ERROR: " );
265+
fprintf( error_file, "ERROR PE%03d: ", what->serial );
266266
vfprintf( error_file, what->message, args );
267267
fputc( '\n', error_file );
268268
ERRORoccurred = true;
269269
} else {
270-
fprintf( error_file, "WARNING: %d", what->severity );
270+
fprintf( error_file, "WARNING PW%03d: %d", what->serial, what->severity );
271271
vfprintf( error_file, what->message, args );
272272
fputc( '\n', error_file );
273273
}
@@ -375,15 +375,15 @@ va_dcl {
375375
heap[child].msg = ERROR_string;
376376

377377
if( what->severity >= SEVERITY_ERROR ) {
378-
sprintf( ERROR_string, "%s:%d: --ERROR: ", sym->filename, sym->line );
378+
sprintf( ERROR_string, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial );
379379
ERROR_string += strlen( ERROR_string );
380380
vsprintf( ERROR_string, what->message, args );
381381
ERROR_string += strlen( ERROR_string );
382382
*ERROR_string++ = '\n';
383383
*ERROR_string++ = '\0';
384384
ERRORoccurred = true;
385385
} else {
386-
sprintf( ERROR_string, "%s:%d: WARNING: ", sym->filename, sym->line );
386+
sprintf( ERROR_string, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
387387
ERROR_string += strlen( ERROR_string );
388388
vsprintf( ERROR_string, what->message, args );
389389
ERROR_string += strlen( ERROR_string );
@@ -402,12 +402,12 @@ va_dcl {
402402
}
403403
} else {
404404
if( what->severity >= SEVERITY_ERROR ) {
405-
fprintf( error_file, "%s:%d: --ERROR: ", sym->filename, sym->line );
405+
fprintf( error_file, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial );
406406
vfprintf( error_file, what->message, args );
407407
fprintf( error_file, "\n" );
408408
ERRORoccurred = true;
409409
} else {
410-
fprintf( error_file, "%s:%d: WARNING: ", sym->filename, sym->line );
410+
fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
411411
ERROR_string += strlen( ERROR_string ) + 1;
412412
vfprintf( error_file, what->message, args );
413413
fprintf( error_file, "\n" );
@@ -437,12 +437,14 @@ void ERRORnospace() {
437437
** Create a new error
438438
*/
439439
Error ERRORcreate( char * message, Severity severity ) {
440+
static int errnum = 0; /* give each error type a unique identifier */
440441
Error n;
441442

442443
n = ( struct Error_ * )sc_malloc( sizeof( struct Error_ ) );
443444
n->message = message;
444445
n->severity = severity;
445446
n->enabled = true;
447+
n->serial = errnum++;
446448
return n;
447449
}
448450

0 commit comments

Comments
 (0)