-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (68 loc) · 2.1 KB
/
main.cpp
File metadata and controls
89 lines (68 loc) · 2.1 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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "./Config.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <sys/stat.h>
#include <cstdio>
#include <cstring>
#include "./Constants/Constants.h"
#include "./Constants/DefineColourConsts.h"
#include "./Assert.h"
#include "./Stack/Stack.h"
#include "./Tree/Tree.h"
#include "./Tree/TreeDump.h"
// #include "./ReadAndWriteFunctions.h"
#include "./Tree/TreeDSL.h"
#include "./FrontEnd/LexicalAnalyzator.h"
#include "./FrontEnd/SyntaxAnalyzator.h"
#include "./FrontEnd/VarTable.h"
#include "./BackEnd/BackEnd.h"
struct Programm
{
FILE* file;
ProgrammTokens* tokens;
Node* tree;
VarTable* var_table;
};
int main()
{
// VarTable* var_table = VarTableCtor();
//
// char s[10] = {};
//
// for (int i = 40; i < 80; i++)
// {
// sprintf(s, "%c", (char) i);
// AddNewVar(var_table, s, (double) i * 3.33);
// }
//
// VarTableDump(var_table);
//
// VarTableDtor(&var_table);
Programm programm = {};
programm.var_table = VarTableCtor();
programm.file = fopen("./Programms/square.vlds", "r");
ASSERT(programm.file != nullptr)
char programm_code[MAX_PROGRAMM_LENGTH] = {};
char* programm_code_ptr = programm_code;
fscanf(programm.file, "%[^EOF]s", programm_code_ptr);
fclose(programm.file);
programm.tokens = ProgrammTokensCtor();
AnalyzeProgrammCode(programm.tokens, programm_code);
ProgrammTokensDump(programm.tokens);
programm.tree = GetProgramm(programm.tokens, programm.var_table);
// ShowTree(programm.tree, SIMPLE_DUMP_MODE, 1);
// ShowTree(programm.tree, FULL_FULL_DUMP_MODE, 1);
// CalculateConstantSubtrees(root);
// TreePreorderPrint(programm_tree, stdout);
// fprintf(stdout, "\n");
FILE* standartized_tree_file = fopen("./FrontEnd/StandartizedTree.txt", "w");
ASSERT(standartized_tree_file != nullptr)
WriteTreeInStandartForm(programm.tree, standartized_tree_file);
fclose(standartized_tree_file);
ProcessProgramm(programm.tree);
ProgrammTokensDtor(&programm.tokens);
VarTableDtor(&programm.var_table);
NodeDtor(&programm.tree);
return 1;
}