Browse Source

Ajout STOP avec arg

Elies Tali 2 years ago
parent
commit
f4356f9d58
7 changed files with 945 additions and 932 deletions
  1. 6
    15
      Fichiers_Tests/progC
  2. 1
    0
      Lex_Yacc/al.lex
  3. 932
    914
      Lex_Yacc/as.dot
  4. 4
    1
      Lex_Yacc/as.y
  5. 1
    1
      Makefile
  6. BIN
      Tables/Fonctions/tab_fonctions.o
  7. 1
    1
      Tables/Instructions/tab_instruc.c

+ 6
- 15
Fichiers_Tests/progC View File

@@ -1,19 +1,10 @@
1
-int g(int y[]){
2
-    int u;
3
-    y[1] = 2;
4
-    return 15;
5
-}
6
-
7
-
8
-int fonction(int p[]){ 
9
-    g(p);
10
-	return 1;
1
+int fonction(int p){ 
2
+	int y = p*3;
3
+	return y;
11 4
 }
12 5
 
13 6
 int main(){
14
-	int b[2];
15
-	int c = fonction(b);
16
-    c = get();
17
-    b[0] = 25;
18
-    printf(b[0]);
7
+	int a;
8
+	int c = fonction(3);
9
+	stop(3);
19 10
 }

+ 1
- 0
Lex_Yacc/al.lex View File

@@ -32,6 +32,7 @@ yyerror (char const *s)
32 32
 "["         { return tOCROCH;}
33 33
 "]" 		{ return tCCROCH;}
34 34
 "get"       { return tGET;}
35
+"stop"      { return tSTOP;}
35 36
 
36 37
 
37 38
 [0-9]+	{ yylval.nombre = atoi(yytext); return tNB; }

+ 932
- 914
Lex_Yacc/as.dot
File diff suppressed because it is too large
View File


+ 4
- 1
Lex_Yacc/as.y View File

@@ -30,7 +30,7 @@ int nbs_instructions_to_patch[10];
30 30
 %token tMUL tDIV tADD tSUB tEQ
31 31
 %token<nombre> tNB tNBEXP
32 32
 %token<id> tID
33
-%token tPRINTF tGET
33
+%token tPRINTF tGET tSTOP
34 34
 %token tERROR
35 35
 %token<nombre> tIF tWHILE tELSE
36 36
 %token tRETURN
@@ -69,6 +69,8 @@ Fonction : Main {print_fonctions();};
69 69
 
70 70
 Get : tGET tOBRACE tCBRACE {int addr = push("0_TEMPORARY", 0, integer); add_operation(GET,addr,0,0); $$ = addr;};
71 71
 
72
+Stop : tSTOP tOBRACE tNB tCBRACE {add_operation(STOP,$3,0,0);};
73
+
72 74
 Return : tRETURN E tPV {add_operation(COP,0,$2,0); pop(); };
73 75
 
74 76
 Args : Arg ArgSuite {$$ = $1 + $2; printf("Les arguments de la fonctions vont avoir une taille dans la pile de : %d\n",$$);};
@@ -90,6 +92,7 @@ Instruction : Invocation tPV{pop();};
90 92
 Instruction : If {};
91 93
 Instruction : While {};
92 94
 Instruction : Return {};
95
+Instruction : Stop tPV {};
93 96
 
94 97
 
95 98
 Invocation : tID tOBRACE {struct fonction_t fonc = get_fonction($1);}

+ 1
- 1
Makefile View File

@@ -21,7 +21,7 @@ clean_Lex_Yacc:
21 21
 	@rm -f Lex_Yacc/as.output Lex_Yacc/as.tab.* Lex_Yacc/lex.yy.*
22 22
 
23 23
 build : clean build_Symboles build_Instructions build_Lex_Yacc build_Fonctions
24
-	gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/Instructions/tab_instruc.o Tables/Symboles/table_symboles.o Tables/Fonctions/tab_fonctions.o -ly -o rondoudou_gcc
24
+	gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/Instructions/tab_instruc.o Tables/Symboles/table_symboles.o Tables/Fonctions/tab_fonctions.o -ll -o rondoudou_gcc
25 25
 
26 26
 build_Symboles: clean_Symboles
27 27
 	gcc -c Tables/Symboles/table_symboles.c -o Tables/Symboles/table_symboles.o

BIN
Tables/Fonctions/tab_fonctions.o View File


+ 1
- 1
Tables/Instructions/tab_instruc.c View File

@@ -77,7 +77,7 @@ char * get_asm_line_from_op(struct operation_t op){
77 77
             sprintf(buffer,"GET %d\n",op.arg1);
78 78
             break;
79 79
         case (STOP):
80
-            sprintf(buffer,"STOP\n");
80
+            sprintf(buffer,"STOP %d\n", op.arg1);
81 81
             break;
82 82
 	}
83 83
 	return buffer;

Loading…
Cancel
Save