-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathifj16.c
52 lines (44 loc) · 1.03 KB
/
ifj16.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
52
/*
* Project: IFJ16, a programming language interpreter
* FIT VUT Brno
* Authors: xzaryb00 - Zarybnický Jakub
* xtamas01 - Tamaškovič Marek
* xvasko12 - Vaško Martin
* xvasko14 - Vaško Michal
* xzales12 - Záleský Jiří
*/
#include "parser.h"
#include "interpret.h"
#include "int_memory_management.h"
#include "sanity.h"
Lexer *l;
Interpret *i;
void freeGlobalResources() {
if (l != NULL)
freeLexer(l);
if (i != NULL)
freeInterpret(i);
free_c_all(&alloc_tab);
}
int main(int argc, char *argv[])
{
if (argc != 2) {
FERROR(ERR_INTERNAL,
"Invalid arguments, usage: %s <FILENAME>\n", argv[0]);
}
FILE *f = fopen(argv[1], "r");
if (f == NULL) {
PERROR("Error while opening file");
}
i = createInterpret();
l = createLexer(f, i);
while (hasMore(l)) {
parseClass(l);
}
fclose(f);
l->file = NULL;
runSemanticAnalysis(&i->symTable);
evalMain(i);
freeGlobalResources();
return 0;
}