-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.cc
More file actions
49 lines (39 loc) · 1.01 KB
/
driver.cc
File metadata and controls
49 lines (39 loc) · 1.01 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
#include "statement-block-generator.h"
#include "statement-machine-code.h"
int main(int argc, char* argv[])
{
if (argc <= 1)
return 1;
if (argc <= 1)
{
std::cout << "Usage ./ncc [file-name]" << '\n';
return 1;
}
Error file_error = lex_init(argv[1]);
if (file_error.error != NCC_OK)
{
return 1;
}
while (!lex_eof())
{
std::unique_ptr<Node> code_tree;
auto error = generate_statement_tree(code_tree);
if (error.error != NCC_OK)
{
print_error(error);
}
else
{
// Print the tree
std::cout << "Code tree:" << '\n';
print_tree(code_tree);
generate_block_code(code_tree);
std::cout << "Code size: " << get_code_size() << " bytes." << '\n';
std::cout << "Code execution:" << '\n';
execute_statement_code();
code_tree.release();
std::cout << '\n';
}
}
return 0;
}