From 5ad57d142bcf05886c750018b067865fc97e13fe Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 26 May 2018 18:45:50 +0200 Subject: Handle output to file option --- src/symbol_table.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/symbol_table.c') diff --git a/src/symbol_table.c b/src/symbol_table.c index 6f84ce4..8e6db97 100644 --- a/src/symbol_table.c +++ b/src/symbol_table.c @@ -4,6 +4,7 @@ */ #include "symbol_table.h" +#include "generator.h" extern int lineno; /* from lexical analyser */ @@ -61,15 +62,15 @@ void glo_display_table() { int count; for (count = 0; count < glo_symbol_table.size; count++) { if (glo_symbol_table.entries[count].type == INT) - printf(";entier: %s, pos: %d \n", + fprintf(output, ";entier: %s, pos: %d \n", glo_symbol_table.entries[count].name, glo_symbol_table.entries[count].addr); else - printf(";caractere: %s, pos: %d \n", + fprintf(output, ";caractere: %s, pos: %d \n", glo_symbol_table.entries[count].name, glo_symbol_table.entries[count].addr); } - printf("\n"); + fprintf(output, "\n"); } void loc_addVar(const char name[], int type) { @@ -127,21 +128,21 @@ void loc_display_table() { int count; for (count = 0; count < loc_symbol_table.size; count++) { if (loc_symbol_table.entries[count].type == INT) - printf(";entier: %s, pos: %d \n", + fprintf(output, ";entier: %s, pos: %d \n", loc_symbol_table.entries[count].name, loc_symbol_table.entries[count].addr); else - printf(";caractere: %s, pos: %d \n", + fprintf(output, ";caractere: %s, pos: %d \n", loc_symbol_table.entries[count].name, loc_symbol_table.entries[count].addr); } - printf("\n"); + fprintf(output, "\n"); } void loc_clean_table() { int i; for (i = 0; i < loc_symbol_table.size; i++) { - printf("pop eax\n"); + fprintf(output, "pop eax\n"); } loc_symbol_table.size = 0; } -- cgit v1.2.3