-
Notifications
You must be signed in to change notification settings - Fork 0
/
defs.h
35 lines (28 loc) · 1.11 KB
/
defs.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
#ifndef DEFS_H
#define DEFS_H
#define SYMBOL_TABLE_LENGTH 64
#define NO_ATR 0
#define NO_RANGE {-1, -1, -1, -1}
#define RANGE(x) {x.first_line, x.first_column, x.last_line, x.last_column}
#define LAST_WORKING_REG 12
#define FUN_REG 13
#define CHAR_BUFFER_LENGTH 128
extern char char_buffer[CHAR_BUFFER_LENGTH];
// Output macros
int yyerror(const char *text);
enum severity { ERROR = 1, WARNING, INFORMATION, HINT };
extern int severity;
#define err(...) sprintf(char_buffer, __VA_ARGS__), \
severity = ERROR, yyerror(char_buffer)
#define warn(...) sprintf(char_buffer, __VA_ARGS__), \
severity = WARNING, yyerror(char_buffer)
// Data types
enum types { NO_TYPE, INT, UINT };
// Kinds of symbols (maximum 32 different kinds)
enum kinds { NO_KIND = 0x1, REG = 0x2, LIT = 0x4,
FUN = 0x8, VAR = 0x10, PAR = 0x20 };
// Arithmetic operators
enum arops { ADD, SUB, MUL, DIV, AROP_NUMBER };
// Relational operators
enum relops { LT, GT, LE, GE, EQ, NE, RELOP_NUMBER };
#endif /* end of include guard: DEFS_H */