From 0255cca32a78847d2de0134740b991a77f5ad555 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 5 Jun 2018 14:56:02 +0200 Subject: Return test --- res/test_read.tpc | 1 + res/test_return.tpc | 13 +++++++++++++ src/generator.c | 2 +- src/tpc.y | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 res/test_return.tpc 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) { caractere r1; readc(r1); print(r1); + return 0; } 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 @@ +/* test-table-symboles.tpc */ + +/* Test file for simplified translator of a declaration of variables in C */ +entier r1,b,s,c,r2 ; +caractere letter, digit, punct; + +entier test(void){ +} + +entier main(void) { + print(test()); + return 0; +} 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) } void gen_function_end_declaration() { - fprintf(output, "mov rsp, rbp\npop rbp\nret\n"); + fprintf(output, "mov rsp, rbp\npop rbp\nret\n"); } void 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: | LValue { $$ = gen_value($1, scope); } | NUM { $$ = gen_num($1, scope); } | CARACTERE { $$ = gen_char($1, scope); } -| IDENT '(' Arguments ')' { return_type = fun_lookup($1,$3);$$ = gen_function_call($1,$3); } +| IDENT '(' Arguments ')' { $$ = gen_function_call($1,$3); } ; LValue: IDENT { gen_check($1, scope); } -- cgit v1.2.3