diff options
author | pacien | 2018-05-26 18:45:50 +0200 |
---|---|---|
committer | pacien | 2018-05-26 18:45:50 +0200 |
commit | 5ad57d142bcf05886c750018b067865fc97e13fe (patch) | |
tree | 3ea20ebe4ca6cb07031280ed015b3cc2af2da857 /src/symbol_table.c | |
parent | 67fc7933df394848eeb86a45f37e35ded032e5e9 (diff) | |
download | tpc-compiler-5ad57d142bcf05886c750018b067865fc97e13fe.tar.gz |
Handle output to file option
Diffstat (limited to 'src/symbol_table.c')
-rw-r--r-- | src/symbol_table.c | 15 |
1 files changed, 8 insertions, 7 deletions
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 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "symbol_table.h" | 6 | #include "symbol_table.h" |
7 | #include "generator.h" | ||
7 | 8 | ||
8 | extern int lineno; /* from lexical analyser */ | 9 | extern int lineno; /* from lexical analyser */ |
9 | 10 | ||
@@ -61,15 +62,15 @@ void glo_display_table() { | |||
61 | int count; | 62 | int count; |
62 | for (count = 0; count < glo_symbol_table.size; count++) { | 63 | for (count = 0; count < glo_symbol_table.size; count++) { |
63 | if (glo_symbol_table.entries[count].type == INT) | 64 | if (glo_symbol_table.entries[count].type == INT) |
64 | printf(";entier: %s, pos: %d \n", | 65 | fprintf(output, ";entier: %s, pos: %d \n", |
65 | glo_symbol_table.entries[count].name, | 66 | glo_symbol_table.entries[count].name, |
66 | glo_symbol_table.entries[count].addr); | 67 | glo_symbol_table.entries[count].addr); |
67 | else | 68 | else |
68 | printf(";caractere: %s, pos: %d \n", | 69 | fprintf(output, ";caractere: %s, pos: %d \n", |
69 | glo_symbol_table.entries[count].name, | 70 | glo_symbol_table.entries[count].name, |
70 | glo_symbol_table.entries[count].addr); | 71 | glo_symbol_table.entries[count].addr); |
71 | } | 72 | } |
72 | printf("\n"); | 73 | fprintf(output, "\n"); |
73 | } | 74 | } |
74 | 75 | ||
75 | void loc_addVar(const char name[], int type) { | 76 | void loc_addVar(const char name[], int type) { |
@@ -127,21 +128,21 @@ void loc_display_table() { | |||
127 | int count; | 128 | int count; |
128 | for (count = 0; count < loc_symbol_table.size; count++) { | 129 | for (count = 0; count < loc_symbol_table.size; count++) { |
129 | if (loc_symbol_table.entries[count].type == INT) | 130 | if (loc_symbol_table.entries[count].type == INT) |
130 | printf(";entier: %s, pos: %d \n", | 131 | fprintf(output, ";entier: %s, pos: %d \n", |
131 | loc_symbol_table.entries[count].name, | 132 | loc_symbol_table.entries[count].name, |
132 | loc_symbol_table.entries[count].addr); | 133 | loc_symbol_table.entries[count].addr); |
133 | else | 134 | else |
134 | printf(";caractere: %s, pos: %d \n", | 135 | fprintf(output, ";caractere: %s, pos: %d \n", |
135 | loc_symbol_table.entries[count].name, | 136 | loc_symbol_table.entries[count].name, |
136 | loc_symbol_table.entries[count].addr); | 137 | loc_symbol_table.entries[count].addr); |
137 | } | 138 | } |
138 | printf("\n"); | 139 | fprintf(output, "\n"); |
139 | } | 140 | } |
140 | 141 | ||
141 | void loc_clean_table() { | 142 | void loc_clean_table() { |
142 | int i; | 143 | int i; |
143 | for (i = 0; i < loc_symbol_table.size; i++) { | 144 | for (i = 0; i < loc_symbol_table.size; i++) { |
144 | printf("pop eax\n"); | 145 | fprintf(output, "pop eax\n"); |
145 | } | 146 | } |
146 | loc_symbol_table.size = 0; | 147 | loc_symbol_table.size = 0; |
147 | } | 148 | } |