This repository was archived by the owner on Oct 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (54 loc) · 1.36 KB
/
Copy pathmain.cpp
File metadata and controls
60 lines (54 loc) · 1.36 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
#ifdef _WIN32
#include <Windows.h>
#endif
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <csignal>
#include <cstdlib>
#include <filesystem>
#include <chrono>
#include <random>
#include "libs/strlib.hpp"
#include "classes/token.hpp"
#include "classes/lexer.hpp"
#include "classes/parser.hpp"
using namespace std;
void finalize(int s) {
cout.clear();
cin.clear();
exit(s);
}
int main(int argc, char * argv[]){
if (argc > 1) {
#ifdef _WIN32
SetConsoleOutputCP(CP_UTF8);
SetConsoleCP(CP_UTF8);
if (split(argv[1], ".").back() == "cdn") { FreeConsole(); }
#endif
string target = argv[1];
ifstream file(target);
if (file.good()) {
signal(SIGINT, finalize);
stringstream code;
code << file.rdbuf();
file.close();
map<int, vector<Token>> tokenlist = {};
vector<string> codelines = split(code.str(), "\n");
Lexer l;
for (int t = 0; t < codelines.size(); t++) {
tokenlist[t] = l.tokenize(l.disassemble(codelines[t]));
}
code.str(std::string());
Parser p(tokenlist, argv, argc);
p.runCode();
finalize(0);
}
}
return 0;
}