diff options
Diffstat (limited to 'src/tpc.y')
-rw-r--r-- | src/tpc.y | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -11,9 +11,10 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <stdio.h> | ||
15 | int nb_globals = 0; | 14 | int nb_globals = 0; |
16 | #include "symbol_table.h" | 15 | #include "symbol_table.h" |
16 | #include <stdio.h> | ||
17 | #include <getopt.h> | ||
17 | #include "generator.h" | 18 | #include "generator.h" |
18 | 19 | ||
19 | extern int lineno; | 20 | extern int lineno; |
@@ -182,5 +183,23 @@ void yyerror(char *msg){ | |||
182 | } | 183 | } |
183 | 184 | ||
184 | int main(int argc, char **argv) { | 185 | int main(int argc, char **argv) { |
186 | char opt; | ||
187 | |||
188 | output = stdout; | ||
189 | while ((opt = getopt(argc, argv, "o:")) != -1) | ||
190 | switch (opt) { | ||
191 | case 'o': | ||
192 | output = fopen(optarg, "w+"); | ||
193 | if (output == NULL) { | ||
194 | perror("Error opening output file: "); | ||
195 | return -1; | ||
196 | } | ||
197 | break; | ||
198 | |||
199 | default: | ||
200 | fputs("Exiting due to invalid option.\n", stderr); | ||
201 | return -1; | ||
202 | } | ||
203 | |||
185 | return yyparse(); | 204 | return yyparse(); |
186 | } | 205 | } |