aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/test_read.tpc1
-rw-r--r--res/test_return.tpc13
-rw-r--r--src/generator.c2
-rw-r--r--src/tpc.y2
4 files changed, 16 insertions, 2 deletions
diff --git a/res/test_read.tpc b/res/test_read.tpc
index 0109e4d..6ad3632 100644
--- a/res/test_read.tpc
+++ b/res/test_read.tpc
@@ -9,4 +9,5 @@ entier main(void) {
9 caractere r1; 9 caractere r1;
10 readc(r1); 10 readc(r1);
11 print(r1); 11 print(r1);
12 return 0;
12} 13}
diff --git a/res/test_return.tpc b/res/test_return.tpc
new file mode 100644
index 0000000..241a1ba
--- /dev/null
+++ b/res/test_return.tpc
@@ -0,0 +1,13 @@
1/* test-table-symboles.tpc */
2
3/* Test file for simplified translator of a declaration of variables in C */
4entier r1,b,s,c,r2 ;
5caractere letter, digit, punct;
6
7entier test(void){
8}
9
10entier main(void) {
11 print(test());
12 return 0;
13}
diff --git a/src/generator.c b/src/generator.c
index d5df545..1181ac7 100644
--- a/src/generator.c
+++ b/src/generator.c
@@ -97,7 +97,7 @@ Type gen_function_declaration(const char name[], int return_type, int nb_param)
97} 97}
98 98
99void gen_function_end_declaration() { 99void gen_function_end_declaration() {
100 fprintf(output, "mov rsp, rbp\npop rbp\nret\n"); 100 fprintf(output, "mov rsp, rbp\npop rbp\nret\n");
101} 101}
102 102
103void gen_function_return(Type expect, Type actual) { 103void gen_function_return(Type expect, Type actual) {
diff --git a/src/tpc.y b/src/tpc.y
index dc6bc4f..14b0ef3 100644
--- a/src/tpc.y
+++ b/src/tpc.y
@@ -164,7 +164,7 @@ F:
164| LValue { $$ = gen_value($<ident>1, scope); } 164| LValue { $$ = gen_value($<ident>1, scope); }
165| NUM { $$ = gen_num($1, scope); } 165| NUM { $$ = gen_num($1, scope); }
166| CARACTERE { $$ = gen_char($1, scope); } 166| CARACTERE { $$ = gen_char($1, scope); }
167| IDENT '(' Arguments ')' { return_type = fun_lookup($<ident>1,$<num>3);$$ = gen_function_call($<ident>1,$<num>3); } 167| IDENT '(' Arguments ')' { $$ = gen_function_call($<ident>1,$<num>3); }
168; 168;
169LValue: 169LValue:
170 IDENT { gen_check($<ident>1, scope); } 170 IDENT { gen_check($<ident>1, scope); }