-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
40 lines (36 loc) · 842 Bytes
/
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
#include "obcScanner.h"
#include "obcParser.h"
#include "obcCompiler.h"
int main(int argc, char** argv)
{
/* Get file from stdin or input arg if there is one*/
file = (argc < 2) ? stdin : fopen(argv[1], "r");
if (!file)
{
perror(argv[1]);
exit(EXIT_FAILURE);
}
initSymTbl();
initTypeTbl();
#if ENABLE_PARSER
printf("\n");
nextSym();
Module();
outFile = fopen("code.txt", "w");
if(numCompErrors == 0)
{
#if PRINT_FNL_COD
printCode();
#endif
outputCode(outFile);
}
else
printf("\n*****Code Not Generated. %d Error(s) And %d Warning(s) Found.*****\n\n", numCompErrors, numCompWarnings);
fclose(outFile);
#else /* Just the scanner*/
while (!EOFflag || (unsigned int)endOfLine+1 != lineBuffPtr)
nextSym();
#endif
fclose(file);
exit(EXIT_SUCCESS);
}