-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.h
More file actions
186 lines (153 loc) · 2.69 KB
/
global.h
File metadata and controls
186 lines (153 loc) · 2.69 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#ifndef COMPILATEURR_GLOBAL_H
#define COMPILATEURR_GLOBAL_H
// includes
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
// Definitions
#define LONGUEUR_MOT 200
#define TAILLE_TOKEN_LISTE 40
// definition d'un boolean
typedef enum _boolean {
false, true
} boolean;
// typedef: enum tokens,
typedef enum
{
NUM_TOKEN,
VAR_TOKEN,
IF_TOKEN,
ELSE_TOKEN,
WHILE_TOKEN,
FOR_TOKEN,
IN_TOKEN,
PV_TOKEN,
PT_TOKEN,
PLUS_TOKEN,
MOINS_TOKEN,
MULT_TOKEN,
DIV_TOKEN,
VIR_TOKEN,
AFF_TOKEN,
INF_TOKEN,
INFEG_TOKEN,
SUP_TOKEN,
SUPEG_TOKEN,
DIFF_TOKEN,
PO_TOKEN,
PF_TOKEN,
ID_TOKEN,
ERREUR_TOKEN,
EOF_TOKEN,
EG_TOKEN,
REPEAT_TOKEN,
OF_TOKEN,
PP_TOKEN,
AO_TOKEN,
AF_TOKEN,
RETURN_TOKEN,
FUNCTION_TOKEN,
HASH_TOKEN,
IFELSE_TOKEN,
TRUE_TOKEN,
FALSE_TOKEN,
AND_TOKEN,
OR_TOKEN,
BREAK_TOKEN,
PRINT_TOKEN,
} CODES_TOKENS;
//CODES_TOKENS Sym_Cour, Sym_Prec;
typedef struct
{
CODES_TOKENS cls;
char nom[25];
} CODES_LEX;
CODES_LEX Sym_Cour, Sym_Prec;
// structs: symbol,
/*
typedef enum
{
TYPE_VAR,
TYPE_CONST,
TYPE_PROGRAM
} type_symoble;
typedef struct
{
type_symoble type;
char nom[20];
int adresse_val;
} Symbole;
typedef struct
{
Symbole *tab;
int taille;
} _tab_symbole;
_tab_symbole tab_symbole;
*/
// Table de symbole
struct symbole_stocke {
char nom[LONGUEUR_MOT];
int valeur;
int addresse;
int longueur;
int offset;
/* Pour les vecteurs */
//int start;
//int end;
};
// Variable declaration
FILE *file;
char Car_Cour, Car_Prec;
int ligne, col, i;
char *chaine_p, chaine[100];
int taille_table_symbole;
int taille_max_table_symbole;
struct symbole_stocke *table_symbole;
int offset;
int PC;
int PH;
int adresse_offset;
//void EXPR();
//void INSTS();
//void INST();
//void COND();
typedef enum
{
NOP,
ADD,
SUB,
MUL,
DIV,
EQL,
NEQ,
GTR,
LSS,
GEQ,
LEQ,
LDA,
LDI,
PRN,
INT,
HLT,
INN,
STO,
LDV,
BZE,
BRN,
} MNEMONIQUES;
typedef struct
{
MNEMONIQUES mne;
int suite;
} instruction;
instruction PCode[50], PileHisto[50];
char *MNEMONIQUESNAMES[21];
void init_pseudo_code();
void generer(MNEMONIQUES M);
void generer_val(MNEMONIQUES M, int val);
void PH_generer(MNEMONIQUES M);
void PH_generer_val(MNEMONIQUES M, int val);
instruction SommetPileHisto();
#endif //COMPILATEURR_GLOBAL_H