-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.h
126 lines (106 loc) · 1.84 KB
/
types.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef TYPES_H_
#define TYPES_H_
#ifdef __linux__
#include <stdint.h>
typedef uint32_t u32;
typedef int32_t s32;
typedef uint8_t u8;
#elif __bubblesos__
#endif
#define MAX_BASIC_TOKS 65536
#define MAX_BASIC_TOKS_P_LINE 100
#define MAX_BASIC_LINES 65536
#define MAX_STR_LEN 255
#define MAX_NUM_DIGITS 10
#define SYMS_LEN 7
#define MAX_SYM_LEN 6
typedef struct sym {
char* name;
u32 argCount;
} sym_t;
static const sym_t SYMBOLS[SYMS_LEN] = {{"PRINT\0", 1}, {"GOTO\0", 1}, {"NEXT\0", 1}, {"FOR\0", 2}, {"TO\0", 1}, {"IF\0", 4}, {"THEN\0", 1}};
typedef enum symbols {
PRINT,
GOTO,
NEXT,
FOR,
TO,
IF,
THEN,
} symbols_t;
typedef enum tokType {
NUM,
STR,
SYM,
END,
VAR,
OP,
COND,
} tokType_t;
typedef struct tok {
tokType_t type;
void* data;
struct tok* nextTok;
struct tok* prevTok;
} tok_t;
typedef struct line {
u32 num;
tok_t* firstTok;
tok_t* lastTok;
u32 tokCnt;
} line_t;
typedef enum opType {
ASG,
ADD,
SUB,
MUL,
DIV,
NOT,
AND,
OR,
XOR,
} opType_t;
typedef enum varType {
VAR_NUM,
VAR_STR,
VAR_VOID,
} varType_t;
typedef struct var {
varType_t type;
void* data;
} var_t;
typedef enum chck {
EQ,
LT,
GT,
LTE,
GTE,
ALWAYS,
} chck_t;
#define CONFIG_VAR 1
#define CONFIG_NUM 0
typedef enum condConfig {
C_NUM_NUM,
C_NUM_VAR,
C_VAR_NUM,
C_VAR_VAR,
} condConfig_t;
typedef struct cond {
chck_t chck;
u8 config;
u32 num1;
u32 num2;
u8 varNum1;
u8 varNum2;
} cond_t;
typedef struct strLine {
struct strLine* prev;
struct strLine* next;
char* line;
u32 num;
} strLine_t;
typedef struct strLines {
strLine_t* head;
strLine_t* tail;
} strLines_t;
#endif // TYPES_H_