-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
70 lines (51 loc) · 1.36 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
============================================================================
Name : Interpreter.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
#include "System.h"
#include "Lexer.h"
#include "AST.h"
#include "Debug_Walker.h"
#include "Parser.h"
#include "Semantic_Analyzer.h"
#include "Symbol_Tables.h"
#include "Interpreter.h"
int main(void) {
s_lexer_lexer Lexer;
s_parser_parser Parser;
s_ast_program* ProgramNode;
FILE* FilePtr;
size_t FileSize;
uint8_t* Text;
size_t ReadSize;
FilePtr = fopen("C:\\Users\\Josip\\eclipse-workspace\\Interpreter\\src\\Interpreter\\Test_Script.txt", "r");
if(FilePtr == NULL)
{
printf("File could not be opened.\n");
exit(1);
}
fseek(FilePtr, 0, SEEK_END);
FileSize = ftell(FilePtr);
rewind(FilePtr);
Text = (uint8_t*) malloc(FileSize);
ReadSize = fread((void*)Text, 1, FileSize, FilePtr);
Text[ReadSize] = 0;
if(ReadSize == 0)
{
printf("File could not be read.\n");
exit(1);
}
Lexer_Init(&Lexer, Text);
Parser_Init(&Parser, &Lexer);
ProgramNode = Parser_Parse(&Parser);
Debug_Walker_Walkthrought(ProgramNode);
Semantic_Analyzer_Walkthrought( ProgramNode );
Interpreter_Walkthrought( ProgramNode );
free((void*)Text);
return EXIT_SUCCESS;
}