|
@@ -31,6 +31,8 @@ Opérations possible :
|
31
|
31
|
#include <string.h>
|
32
|
32
|
#include <stdio.h>
|
33
|
33
|
|
|
34
|
+int last_addr = 0;
|
|
35
|
+
|
34
|
36
|
struct element_t {
|
35
|
37
|
struct symbole_t symbole;
|
36
|
38
|
struct element_t * suivant;
|
|
@@ -40,6 +42,8 @@ struct pile_t {
|
40
|
42
|
int taille;
|
41
|
43
|
struct element_t * first;
|
42
|
44
|
};
|
|
45
|
+*
|
|
46
|
+struct pile_t * pile;
|
43
|
47
|
|
44
|
48
|
char * type_to_string(enum type_t type) {
|
45
|
49
|
if (type == INT) {
|
|
@@ -51,9 +55,9 @@ char * type_to_string(enum type_t type) {
|
51
|
55
|
|
52
|
56
|
void print_symbole(struct symbole_t symbole) {
|
53
|
57
|
if (symbole.initialized) {
|
54
|
|
- printf("\t\t{nom:%s, adresse:%p, type:%s, initialized:OUI}\n", symbole.nom, (void *)(symbole.adresse), type_to_string(symbole.type));
|
|
58
|
+ printf("\t\t{nom:%s, adresse:%p, type:%s, initialized:OUI, profondeur : %d}\n", symbole.nom, (void *)(symbole.adresse), type_to_string(symbole.type), symbole.profondeur);
|
55
|
59
|
} else {
|
56
|
|
- printf("\t\t{nom:%s, adresse:%p, type:%s, initialized:NON}\n", symbole.nom, (void *)(symbole.adresse), type_to_string(symbole.type));
|
|
60
|
+ printf("\t\t{nom:%s, adresse:%p, type:%s, initialized:NON, profondeur : %d}\n", symbole.nom, (void *)(symbole.adresse), type_to_string(symbole.type),symbole.profondeur);
|
57
|
61
|
}
|
58
|
62
|
}
|
59
|
63
|
|
|
@@ -63,7 +67,7 @@ void init (void) {
|
63
|
67
|
pile->taille = 0;
|
64
|
68
|
}
|
65
|
69
|
|
66
|
|
-void push(struct symbole_t symbole, struct pile_t * pile) {
|
|
70
|
+void push(char * nom, int isInit, enum type_t type) {
|
67
|
71
|
struct element_t * aux = malloc(sizeof(struct element_t));
|
68
|
72
|
aux->symbole = symbole;
|
69
|
73
|
aux->suivant = pile->first;
|
|
@@ -71,7 +75,7 @@ void push(struct symbole_t symbole, struct pile_t * pile) {
|
71
|
75
|
pile->taille++;
|
72
|
76
|
}
|
73
|
77
|
|
74
|
|
-struct symbole_t pop(struct pile_t * pile) {
|
|
78
|
+struct symbole_t pop() {
|
75
|
79
|
struct symbole_t retour = {"", 0, UNKNOWN, 0};
|
76
|
80
|
struct element_t * aux;
|
77
|
81
|
if (pile->taille > 0) {
|
|
@@ -84,7 +88,7 @@ struct symbole_t pop(struct pile_t * pile) {
|
84
|
88
|
return retour;
|
85
|
89
|
}
|
86
|
90
|
|
87
|
|
-char status(char * nom, struct pile_t * pile) {
|
|
91
|
+char status(char * nom) {
|
88
|
92
|
char retour = 0;
|
89
|
93
|
struct element_t * aux = pile->first;
|
90
|
94
|
int i;
|
|
@@ -103,7 +107,22 @@ char status(char * nom, struct pile_t * pile) {
|
103
|
107
|
return retour;
|
104
|
108
|
}
|
105
|
109
|
|
106
|
|
-void print(struct pile_t * pile) {
|
|
110
|
+struct symbole_t * getVariable(char * nom){
|
|
111
|
+ struct symbole_t * retour = NULL;
|
|
112
|
+ struct element_t * aux = pile->first;
|
|
113
|
+ int i;
|
|
114
|
+ for (i=0; i < pile->taille; i++) {
|
|
115
|
+ if (!strcmp(nom, aux->symbole.nom)) {
|
|
116
|
+ retour = element_t;
|
|
117
|
+ break;
|
|
118
|
+ } else {
|
|
119
|
+ aux = aux->suivant;
|
|
120
|
+ }
|
|
121
|
+ }
|
|
122
|
+ return retour;
|
|
123
|
+}
|
|
124
|
+
|
|
125
|
+void print() {
|
107
|
126
|
printf("Affichage de la Table des Symboles\n\tSize : %d\n\tContenu : \n", pile->taille);
|
108
|
127
|
struct element_t * aux = pile->first;
|
109
|
128
|
int i;
|