-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrorshandling.h
executable file
·39 lines (35 loc) · 1.46 KB
/
errorshandling.h
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
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef ERRORSHANDLING_H
#define ERRORSHANDLING_H
#include <stdio.h>
#include "moduleanalyzing.h"
extern int LC;
/*Raise a parser error */
#define raiseParserError(error) {\
fprintf(stderr, "%s:%d:""\x1b[31m" "error" "\x1b[0m" ": %s\n", getCurModuleName(), LC , error);\
firstpassErrorFlag = 1;\
}
/*Raise a warning */
#define raiseWarning(warning){\
fprintf(stderr, "%s:%d:""\x1b[35m" "warning" "\x1b[0m" ": %s\n", getCurModuleName(), LC , warning);\
}
/*Raise an adressing method error */
#define raiseAdressingMethodError(error , addrm){\
fprintf(stderr, "%s:%d:""\x1b[31m" "error" "\x1b[0m" ": %s " ":adressing method %d is not allowed\n",getCurModuleName(), LC , error , addrm);\
firstpassErrorFlag =1;\
}
/*Symbol errors */
#define raiseSymError(sym_name){\
extern int firstpassErrorFlag;\
fprintf(stderr, "%s:%d:""\x1b[31m" "error" "\x1b[0m" ": Symbol name '%s' is already exist\n", getCurModuleName(), LC , sym_name);\
firstpassErrorFlag = 1;\
}
/*Raise error occured during the second pass */
#define secondPassError(error, name){\
if (name != NULL)\
fprintf(stderr, "%s:%d:""\x1b[31m" "error" "\x1b[0m" ": %s : '%s'\n", getCurModuleName(), LC ,error, name);\
else{\
fprintf(stderr, "Error , line %d %s\n", LC , error);\
}\
secondpassErrorFlag = 1;\
}
#endif /*ERRORSHANDLING_H*/