-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.c
51 lines (41 loc) · 1.41 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/********************************************************************/
/* */
/* */
/* MAIN ROUTINE */
/* */
/* */
/* */
/********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "symbol.h"
#include "tac.h"
extern int yyparse(void);
extern void init_table(void);
extern SYMBTABLE *main_symbol_table;
extern SYMBTABLE *constant_symbol_table;
extern FILE *yyin;
extern int yydebug;
extern TAC *program_tac;
void yyerror(char* text){
printf("Error parsing, %s\n", text);
}
int main(int argc, char* argv[]){
// set this to 1 if you want to see yacc debug output
yydebug = 0;
yyin = fopen(argv[1], "r");
int len = strlen(argv[1]);
input_file_name = (char*)safe_malloc(sizeof(char));
strcpy(input_file_name, argv[1]);
if(!yyparse()){
//dump_table(main_symbol_table);
//dump_constant_table(constant_symbol_table);
//dump_tac(program_tac);
cg(program_tac);
}
else
printf("The file fails to parse.\n");
fclose(yyin);
return 0;
}