-
Notifications
You must be signed in to change notification settings - Fork 0
/
compilateur.c
39 lines (36 loc) · 982 Bytes
/
compilateur.c
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
#include "global.h"
#include "analyseur_syntaxique.h"
#include "pseudo_code.h"
int main(int argc, char **argv)
{
if (argc != 2){
printf("no input file\n");
printf("Usage : %s FILE\n", argv[0]);
exit(0);
}
printf("La liste des tokens : \n");
ligne = 1;
col = 1;
init_table_symbole();
init_pseudo_code();
file = fopen(argv[1], "r+");
Car_Cour = fgetc(file);
do
{
sym_suiv();
INST();
} while(Car_Cour!=EOF);
afficher_table_symbole();
printf("Le pseudo-code :\n\n");
for (int i = 0; i <= PC; i++)
{
if (PCode[i].mne == LDI || PCode[i].mne == LDA || PCode[i].mne == INT || PCode[i].mne == BZE || PCode[i].mne == BRN)
{
printf("%3d : %s %d\n",i, MNEMONIQUESNAMES[PCode[i].mne], PCode[i].suite);
}
else
{
printf("%3d : %s\n",i, MNEMONIQUESNAMES[PCode[i].mne]);
}
}
}