-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonIncludes.h
More file actions
111 lines (100 loc) · 3.71 KB
/
Copy pathcommonIncludes.h
File metadata and controls
111 lines (100 loc) · 3.71 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef commonIncludes_H
#define commonIncludes_H
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <string.h>
class SymbolTable;
class Expression;
class FunctionDetails;
class Vector;
class TypeNode;
class ValueNode;
class ArrayType;
class ArrayIndexing;
class Span;
using namespace std;
enum types
{
INT,
FLOAT,
CHAR,
BOOL,
STRING,
VOID,
OTHER,
ARRAY,
USER_TYPE
};
enum visibilityType
{
PRIVATE,
PUBLIC
};
enum scopeType
{
OTHER_SCOPE,
CLASS_SCOPE,
FUNC_SCOPE,
};
enum AssignResult
{
DIFTYPE,
OK,
ISCONST,
OTHERAR
};
enum Colours
{
IDCOL,
TYPECOL,
DEFAULTCOL,
CFCOL,
VALCOL
};
string col_2_ansi(Colours col);
void printType(types type);
string types_2_str(types type);
extern int gRow;
extern int gCol;
extern SymbolTable *rootSymbolTable;
extern SymbolTable *currentSymbolTable;
extern vector<int> arrayStack;
extern TypeNode *arrayType;
extern Expression *gReturnExpr;
extern visibilityType currentVisibility;
extern bool ignore_after_return_statement;
extern int debug_count;
extern Span gTempSpan;
void debug_print(string s);
class RawNode;
#define semantic_error(message, ...) \
do \
{ \
int debug_option = 1; \
if (!debug_option) \
continue; \
char buffer_x[300]; \
snprintf(buffer_x, sizeof(buffer_x), "SEMANTIC ERROR : "); \
snprintf(buffer_x + strlen(buffer_x), sizeof(buffer_x) - strlen(buffer_x), message, ##__VA_ARGS__); \
printf("\033[38;5;196m%s\033[0m\n", buffer_x); \
} while (0)
#define spanned_semantic_error(span, message, ...) \
{ \
if (span) \
printf("\033[38;5;196mat %s...", span->span_to_string().c_str()); \
semantic_error(message, ##__VA_ARGS__); \
}
#define debug_print(message, ...) \
do \
{ \
int debug_option = 0; \
if (!debug_option) \
continue; \
char buffer_x[300]; \
snprintf(buffer_x, sizeof(buffer_x), "debug: "); \
snprintf(buffer_x + strlen(buffer_x), sizeof(buffer_x) - strlen(buffer_x), message, ##__VA_ARGS__); \
printf("%s\n", buffer_x); \
} while (0)
#endif