-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.cpp
More file actions
27 lines (24 loc) · 810 Bytes
/
error.cpp
File metadata and controls
27 lines (24 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// error.cpp
#include "error.h"
#include <cstring>
#include <cstdlib>
#include <cstdio>
struct error errorTable[5000];
int errorCount = 0;
void addError(int line, const char *message, const char *token) {
// Check if the same error already exists
for (int i = 0; i < errorCount; i++) {
if (errorTable[i].line == line && strcmp(errorTable[i].message, message) == 0 && strcmp(errorTable[i].token, token) == 0) {
return; // Error already exists, do not add it again
}
}
if (errorCount < 5000) {
errorTable[errorCount].line = line;
errorTable[errorCount].message = strdup(message);
errorTable[errorCount].token = strdup(token);
errorCount++;
} else {
fprintf(stderr, "Error:\n\nToo many errors\n");
exit(1);
}
}