-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (37 loc) · 720 Bytes
/
Copy pathmain.cpp
File metadata and controls
46 lines (37 loc) · 720 Bytes
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
#include <iostream>
#include <functional>
#include <typeinfo>
#include <string>
#include <fstream>
#include "Compiler.h"
std::string LoadFromFile(const char* path)
{
std::string result;
std::ifstream in(path, std::ios::in);
if (in.is_open())
{
while (!in.eof())
{
static char tmp[128];
in.getline(tmp, sizeof tmp);
result += tmp;
result += '\n';
}
}
return result;
}
void main()
{
std::string code = LoadFromFile("code.txt");
if (!code.empty())
{
std::ofstream file("out.txt", std::ios::out);
SmallTranslator::Compiler comp(const_cast<char*>(code.c_str()));
std::string result = comp.Compile();
file << result;
std::cout << result;
file.close();
}
getchar();
return;
}