aboutsummaryrefslogtreecommitdiff
path: root/src/tpc.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/tpc.y')
-rw-r--r--src/tpc.y21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/tpc.y b/src/tpc.y
index 6da63ef..b5ab84c 100644
--- a/src/tpc.y
+++ b/src/tpc.y
@@ -11,9 +11,10 @@
11 * 11 *
12 */ 12 */
13 13
14#include <stdio.h>
15int nb_globals = 0; 14int 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
19extern int lineno; 20extern int lineno;
@@ -182,5 +183,23 @@ void yyerror(char *msg){
182} 183}
183 184
184int main(int argc, char **argv) { 185int 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}