|
@@ -113,7 +113,7 @@ DebutAff : tID {struct symbole_t * symbole = get_variable($1); symbole->initial
|
113
|
113
|
DebutAffPointeur : tMUL SuiteAffPointeur {add_operation(READ, $2, $2, 0); $$=$2;};
|
114
|
114
|
DebutAffPointeur : SuiteAffPointeur {$$=$1;};
|
115
|
115
|
SuiteAffPointeur : tMUL tID {struct symbole_t * symbole = get_variable($2); int addr = push("0_TEMPORARY", 1, symbole->type); add_operation(COP, addr,symbole->adresse,0); $$=addr;};
|
116
|
|
-SuiteAffPointeur : tID tOCROCH E tCCROCH {struct symbole_t * symbole = get_variable($1); int addr = push("0_TEMPORARY", 1, symbole->type); add_operation(AFC, addr,symbole->adresse,0); int addr2 = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr2, taille_types[symbole->type.base],0); add_operation(MUL,$3,addr2,$3); add_operation(ADD,$3,addr,$3); $$=$3; pop(); pop();};
|
|
116
|
+SuiteAffPointeur : tID tOCROCH E tCCROCH {struct symbole_t * symbole = get_variable($1); int addr = push("0_TEMPORARY", 1, symbole->type); if (symbole->type.pointeur_level > 0){add_operation(COP, addr,symbole->adresse,0);} else{add_operation(AFCA, addr,symbole->adresse,0);} int addr2 = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr2, taille_types[symbole->type.base],0); add_operation(MUL,$3,addr2,$3); add_operation(ADD,$3,addr,$3); $$=$3; pop(); pop();};
|
117
|
117
|
|
118
|
118
|
|
119
|
119
|
E : tNB { int addr = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr,$1,0); $$ = addr;};
|
|
@@ -134,16 +134,16 @@ E : E tOR E {add_operation(ADD,$1,$1,$3); $$ = $1; pop();} ;
|
134
|
134
|
E : tMUL E { add_operation(READ, $2, $2, 0); $$=$2;};
|
135
|
135
|
E : tADDR EBis {add_operation(COPA,$2, $2,0); $$=$2;};
|
136
|
136
|
E : tADDR ETer {add_operation(COPA,$2, $2,0); $$=$2;};
|
137
|
|
-E : tID tID { printf("Id\n"); struct symbole_t * symbole = get_variable($1); int addr = allocate_mem_temp_var(symbole->type.base); add_operation(COP, addr,symbole->adresse,0); $$=addr;};
|
138
|
|
-E : tID tOCROCH E tCCROCH {struct symbole_t * symbole = get_variable($1); int addr = allocate_mem_temp_var(symbole->type.base); add_operation(AFC, addr,symbole->adresse,0); int addr2 = allocate_mem_temp_var(INT); add_operation(AFC, addr2, taille_types[symbole->type.base],0); add_operation(MUL,$3,addr2,$3); add_operation(ADD,$3,addr,$3); add_operation(READ,$3,$3,0); $$=$3; decrement_temp_var(); decrement_temp_var();};
|
|
137
|
+E : tID { printf("Id\n"); struct symbole_t * symbole = get_variable($1); struct type_t type = symbole->type; type.nb_blocs = 1; int addr = push("0_TEMPORARY", 1, type); if (symbole->type.isTab){add_operation(AFCA, addr,symbole->adresse,0); } else{add_operation(COP, addr,symbole->adresse,0);} $$=addr;};
|
|
138
|
+E : tID tOCROCH E tCCROCH {struct symbole_t * symbole = get_variable($1); struct type_t type = symbole->type; type.nb_blocs = 1; int addr = push("0_TEMPORARY", 1, type); if(type.pointeur_level > 0) {add_operation(COP, addr,symbole->adresse,0);} else{add_operation(AFCA, addr,symbole->adresse,0);} int addr2 = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr2, taille_types[symbole->type.base],0); add_operation(MUL,$3,addr2,$3); add_operation(ADD,$3,addr,$3); add_operation(READ,$3,$3,0); $$=$3; pop(); pop();};
|
139
|
139
|
|
|
140
|
+EBis : tID tOCROCH E tCCROCH {struct symbole_t * symbole = get_variable($1); struct type_t type = symbole->type; type.nb_blocs = 1; int addr = push("0_TEMPORARY", 1, type); if(type.pointeur_level > 0) {add_operation(COP, addr,symbole->adresse,0);} else{add_operation(AFCA, addr,symbole->adresse,0);} int addr2 = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr2, taille_types[symbole->type.base],0); add_operation(MUL,$3,addr2,$3); add_operation(ADD,$3,addr,$3); $$=$3; pop(); pop();};
|
|
141
|
+ETer : tID { printf("Id\n"); struct symbole_t * symbole = get_variable($1); struct type_t type = symbole->type; type.nb_blocs = 1; int addr = push("0_TEMPORARY", 1, type); add_operation(AFCA, addr,symbole->adresse,0); $$=addr;};
|
140
|
142
|
|
141
|
|
-EBeforeAddr : tID tOCROCH E tCCROCH {struct symbole_t * symbole = get_variable($1); int addr = push("0_TEMPORARY", 1, symbole->type); add_operation(AFC, addr,symbole->adresse,0); int addr2 = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr2, taille_types[symbole->type.base],0); add_operation(MUL,$3,addr2,$3); add_operation(ADD,$3,addr,$3); add_operation(READ,$3,$3,0); $$=$3; pop(); pop();};
|
142
|
|
-EBeforeAddr : tID { printf("Id\n"); struct symbole_t * symbole = get_variable($1); int addr = push("0_TEMPORARY", 1, symbole->type); add_operation(COP, addr,symbole->adresse,0); $$=addr;};
|
143
|
143
|
|
144
|
144
|
|
145
|
145
|
//Créer un champ isConst dans la table des symboles
|
146
|
|
-Type : tINT {type_courant.base = INT; type_courant.pointeur_level = 0; type_courant.nb_blocs = 1; printf("Type int\n");} ;
|
|
146
|
+Type : tINT {type_courant.base = INT; type_courant.pointeur_level = 0; type_courant.isTab = 0; type_courant.nb_blocs = 1; printf("Type int\n");} ;
|
147
|
147
|
Type : Type tMUL {type_courant.pointeur_level++; printf("Type int *\n");};
|
148
|
148
|
//SuiteType : tMUL SuiteType {type_courant.pointeur_level++; printf(" * en plus\n");} ;
|
149
|
149
|
//SuiteType : ;
|
|
@@ -153,7 +153,7 @@ Decl : tCONST Type SuiteDeclConst FinDeclConst;
|
153
|
153
|
|
154
|
154
|
SuiteDecl : tID {push($1, 0, type_courant); printf("Suite Decl\n");};
|
155
|
155
|
SuiteDecl : tID tEQ E {pop(); int addr = push($1,1, type_courant);};
|
156
|
|
-SuiteDecl : tID tOCROCH tNB tCCROCH {type_courant.pointeur_level++; type_courant.nb_blocs = $3; push($1, 0, type_courant);} ;
|
|
156
|
+SuiteDecl : tID tOCROCH tNB tCCROCH {type_courant.isTab = 1; type_courant.nb_blocs = $3; push($1, 0, type_courant);} ;
|
157
|
157
|
FinDecl : tPV { printf("Fin Decl\n");};
|
158
|
158
|
FinDecl : tCOMA SuiteDecl FinDecl ;
|
159
|
159
|
|