From 8902053fa7cc5cf6b3ef64a805844455971b99d6 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Wed, 6 Jun 2018 01:49:21 +0200 Subject: Fixing \n in errors, updating commands in report --- doc/rapport.md | 9 +++++++++ src/generator.c | 10 +++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/doc/rapport.md b/doc/rapport.md index d3adc07..1909bbb 100644 --- a/doc/rapport.md +++ b/doc/rapport.md @@ -4,6 +4,15 @@ author: [Pacien TRAN-GIRARD, Adam NAILI] date: 2018-02-20 ... +# Usage + Après un `make`, `./tcompil < prog.tpc [-o prog.asm]` + + Pour faciliter les tests, + `make test FILE_TEST=test_file` + test_file est en réalité un fichier d'extension .tpc placé dans le répertoire res. (exemple: res/test_file.tpc). + Ceci génère un executable `test_file` dans le répertoire out. + + # Analyse lexicale L'analyse lexicale est réalisée avec Flex et est contenue dans le fichier `tpc.lex`. diff --git a/src/generator.c b/src/generator.c index 5c51d3b..1dfe8f3 100644 --- a/src/generator.c +++ b/src/generator.c @@ -121,7 +121,7 @@ void gen_function_end_declaration(const char name[], int return_type, void gen_function_return(Type expect, Type actual) { if (actual != expect) { - fprintf(stderr, "Return type mismatch at line %d.", lineno); + fprintf(stderr, "Return type mismatch at line %d.\n", lineno); exit(1); } if (actual != VOID_T) @@ -487,15 +487,11 @@ int gen_value_tab(const char ident[], Scope scope) { } } int gen_num(int value, Scope scope) { - if (scope == LOCAL) - fprintf(output, "push %d\n", value); // TODO: remove if? - // stored for the semantic analysis. - + fprintf(output, "push %d\n", value); return INT; } int gen_char(int value, Scope scope) { - if (scope == LOCAL) - fprintf(output, "push %d\n", value); // TODO: remove if? + fprintf(output, "push %d\n", value); return CHAR; } -- cgit v1.2.3