-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
43 lines (36 loc) · 1.15 KB
/
main.c
File metadata and controls
43 lines (36 loc) · 1.15 KB
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
#include"lex.h"
#include "stack.h"
#include "hashmap.h"
#include<stdio.h>
#include "parse.tab.h"
#include<stdlib.h>
#include"ast.h"
#include"globals.h"
#include"cgen.h"
int main(int argc, char** argv) {
//inputFileName = argv[1];
if(argc < 2){
fprintf(stderr, "Error: Too Few Arguments in Program, The correct way to run the program is:\n ./golf gen.t1\n Exiting Program\n");
exit(EXIT_FAILURE);
}
if(argc > 2){
fprintf(stderr, "Error: Too Many Arguments in Program, The correct way to run the program is:\n ./golf gen.t1\n Exiting Program\n");
exit(EXIT_FAILURE);
}
yyin = fopen(argv[1], "r");
if (yyin == NULL) {
fprintf(stderr, "Error: Bad File Name '%s', The correct way to run the program is: \n ./golf gen.t1\n Exiting Program\n",argv[1]);
exit(EXIT_FAILURE);
}
gimmeGlobals();
if(yyparse() != 0) {
return EXIT_FAILURE;
}
// Semantic Checker
pSemanticsAst(program);
// This here is the AST Printing, disabled for Final Submission.
//pShowAst(program);
// Code Generation
pCodeGenC(program);
exit(EXIT_SUCCESS);
}