|
@@ -8,6 +8,7 @@
|
8
|
8
|
#include <string.h>
|
9
|
9
|
#include <stdlib.h>
|
10
|
10
|
#include "../Tables/Instructions/tab_instruc.h"
|
|
11
|
+#include "../Tables/Fonctions/tab_fonctions.h"
|
11
|
12
|
#define TAILLE 1024
|
12
|
13
|
|
13
|
14
|
struct type_t type_courant;
|
|
@@ -41,7 +42,7 @@ int nbs_instructions_to_patch[10];
|
41
|
42
|
%left tADD tSUB
|
42
|
43
|
%left tMUL tDIV
|
43
|
44
|
|
44
|
|
-%type<nombre> E Invocation DebutAff SuiteAffPointeur DebutAffPointeur EBis ETer
|
|
45
|
+%type<nombre> E DebutAff SuiteAffPointeur DebutAffPointeur EBis ETer
|
45
|
46
|
|
46
|
47
|
|
47
|
48
|
|
|
@@ -55,10 +56,18 @@ Main : tINT tMAIN tOBRACE Params tCBRACE Body { print(); create_asm();} ;
|
55
|
56
|
|
56
|
57
|
Params : { printf("Sans Params\n"); } ;
|
57
|
58
|
Params : Param SuiteParams ;
|
58
|
|
-Param : Type tID { printf("Prametre : %s\n", $2); };
|
|
59
|
+Param : Type tID { printf("Parametre : %s\n", $2); };
|
59
|
60
|
SuiteParams : tCOMA Param SuiteParams ;
|
60
|
61
|
SuiteParams : ;
|
61
|
62
|
|
|
63
|
+
|
|
64
|
+Args : Arg ArgSuite;
|
|
65
|
+Args : ;
|
|
66
|
+Arg : Type tID {int addr = push($2,1, type_courant);};
|
|
67
|
+ArgSuite : tCOMA Arg ArgSuite {} ;
|
|
68
|
+ArgSuite : ;
|
|
69
|
+
|
|
70
|
+
|
62
|
71
|
Body : tOBRACKET {inc_prof();} Instructions tCBRACKET {print(); reset_prof();} ;
|
63
|
72
|
|
64
|
73
|
|
|
@@ -66,7 +75,7 @@ Instructions : Instruction Instructions ;
|
66
|
75
|
Instructions : ;
|
67
|
76
|
Instruction : Aff {};
|
68
|
77
|
Instruction : Decl {};
|
69
|
|
-Instruction : Invocation tPV{};
|
|
78
|
+//Instruction : Invocation tPV{};
|
70
|
79
|
Instruction : If {};
|
71
|
80
|
Instruction : While {};
|
72
|
81
|
|
|
@@ -122,7 +131,7 @@ E : E tMUL E { printf("Mul\n"); add_operation(MUL,$1,$1,$3); $$ = $1; pop();};
|
122
|
131
|
E : E tDIV E { printf("Div\n"); add_operation(DIV, $1,$1,$3); $$ = $1; pop();};
|
123
|
132
|
E : E tSUB E { printf("Sub\n"); add_operation(SOU,$1,$1,$3); $$ = $1; pop();};
|
124
|
133
|
E : E tADD E { printf("Add\n"); add_operation(ADD,$1,$1,$3); $$ = $1; pop();};
|
125
|
|
-E : Invocation { printf("Invoc\n"); int addr = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr,$1,0); $$ = addr;};
|
|
134
|
+//E : Invocation { printf("Invoc\n"); int addr = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr,$1,0); $$ = addr;};
|
126
|
135
|
E : tOBRACE E tCBRACE { printf("Parentheses\n"); $$=$2;};
|
127
|
136
|
E : tSUB E { printf("Moins\n"); int addr = push("0_TEMPORARY", 1, integer); add_operation(AFC, addr,0,0); add_operation(SOU, $2,$2,addr); $$ = $2; pop();};
|
128
|
137
|
E : E tEQCOND E { printf("==\n"); add_operation(EQU,$1,$1,$3); $$ = $1; pop();};
|
|
@@ -161,36 +170,8 @@ SuiteDeclConst : tID tEQ E {pop(); int addr = push($1,1, type_courant);};
|
161
|
170
|
FinDeclConst : tPV;
|
162
|
171
|
FinDeclConst : tCOMA SuiteDeclConst FinDeclConst;
|
163
|
172
|
|
|
173
|
+Fonction : Type tID {push_fonction($2,type_courant,get_current_index());} tOBRACE {} Args {} tCBRACE Body { printf("Déclaration de la fonction %s\n", $1); } ;)
|
164
|
174
|
|
165
|
|
-/* //Créer un champ isConst dans la table des symboles
|
166
|
|
-DeclType : tINT {type_courant = INT; printf("Type int\n");} ;
|
167
|
|
-
|
168
|
|
-Decl : tCONST DeclType SuiteDeclConst { } ;
|
169
|
|
-SuiteDeclConst : tCOMA tID SuiteDeclConst ;
|
170
|
|
-SuiteDeclConst : tEQ E tPV { };
|
171
|
|
-SuiteDeclConst : tPV { };
|
172
|
|
-
|
173
|
|
-
|
174
|
|
-Decl : DeclType Decl SuiteDecl { } ;
|
175
|
|
-Decl : tID {push($1, 0, type_courant);};
|
176
|
|
-Decl : tID tEQ E {int addr = push($1,1, type_courant); add_operation(AFC, addr,$3,0);} ;
|
177
|
|
-SuiteDecl : tCOMA Decl SuiteDecl { };
|
178
|
|
-SuiteDecl : tPV { };
|
179
|
|
-*/
|
180
|
|
-
|
181
|
|
-Invocation : tPRINTF tOBRACE tID tCBRACE { printf("Appel de printf sur %s\n", $3); } ;
|
182
|
|
-
|
183
|
|
-/*S : E tPV
|
184
|
|
- { printf("RES: %d\n", $1); }
|
185
|
|
- S
|
186
|
|
- | { printf("END\n"); }
|
187
|
|
- ;
|
188
|
|
-
|
189
|
|
-E : E tADD E { $$ = $1 + $3; }
|
190
|
|
- | E tSUB E { $$ = $1 - $3; }
|
191
|
|
- | tOB E tCB { $$ = $2; }
|
192
|
|
- | tNB { $$ = $1; }
|
193
|
|
- ;*/
|
194
|
175
|
|
195
|
176
|
%%
|
196
|
177
|
void main(void) {
|