This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
78 lines (75 loc) · 2.39 KB
/
main.cpp
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
#define __IO__
#define __TRANSPILER__
#include<other.hpp>
#include<errors.hpp>
#include<transpiler.hpp>
#include<API.hpp>
int main(int argc, char** argv)
{
using std::literals::operator ""s;
std::regex file_cpps(R"(^[^\-][a-zA-Z_\-0-9]*?\.cpps$)");
std::regex file_cpp(R"(^[^\-][a-zA-Z_\-0-9]*?\.cpp$)");
// std::regex file(R"(^[^\-][a-zA-Z_\-0-9]*?$)");
if(argc == 4)
{
bool match_file_1_in = std::regex_match(std::string(argv[1]), file_cpps);
bool match_file_2_out = std::regex_match(std::string(argv[2]), file_cpp);
bool match_file_3_in = std::regex_match(std::string(argv[3]), file_cpps);
bool match_file_3_out = std::regex_match(std::string(argv[3]), file_cpp);
if(match_file_1_in)
{
if(std::string(argv[2]) == "-o")
{
if(match_file_3_out)
{
std::ifstream cpps(argv[1]);
std::ofstream cpp(argv[3]);
return transpile(cpps, cpp);
}
else
{
Abort::NoFileSpecified("output");
return NOFILE;
}
}
}
else if(std::string(argv[1]) == "-o")
{
if(match_file_2_out)
{
if(match_file_3_in)
{
std::ifstream cpps(argv[3]);
std::ofstream cpp(argv[2]);
return transpile(cpps, cpp);
}
else
{
Abort::NoFileSpecified("input");
return NOFILE;
}
}
else
{
Abort::NoFileSpecified("output");
return NOFILE;
}
}
else
{
Abort::UnrecognisedArg(std::string(argv[1]));
return UNRECOGNISEDARG;
}
}
else if(argc == 2)
{
if(std::string(argv[1]) == "-h"s || std::string(argv[1]) == "--help"s) return help();
else if(std::string(argv[1]) == "-v"s || std::string(argv[1]) == "--version"s) return version();
else
{
Abort::UnrecognisedArg(std::string(argv[1]));
return UNRECOGNISEDARG;
}
}
else if(argc == 1) return help();
}