43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
#include <iostream>
|
|
#include <set>
|
|
using namespace std;
|
|
|
|
#include "headers/misc.hpp"
|
|
|
|
int main(int argc, char* argv[]) {
|
|
if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << getVersion() << endl; exit(EXIT_SUCCESS); }
|
|
string target = ".lua";
|
|
string_view currentArg;
|
|
bool printResult = false;
|
|
if (argc > 0) {
|
|
vector<string_view> files;
|
|
for (signed int i = 0; i < argc; ++i)
|
|
{
|
|
currentArg = static_cast<string_view>(argv[i]);
|
|
if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true;
|
|
else if (currentArg.starts_with("--target=")) {
|
|
currentArg.remove_prefix(9);
|
|
(target = '.') += currentArg;
|
|
}
|
|
else if (currentArg.ends_with(".ybcon")) files.push_back(currentArg);
|
|
}
|
|
if (!files.empty()) {
|
|
const set<string_view> uniqueFiles(files.begin(), files.end());
|
|
for (string_view fileName: uniqueFiles) {
|
|
if (fileName != "none") {
|
|
const string transpiledString = transpile(parseString(getFileContent(fileName.data())), target);
|
|
if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n";
|
|
fileName.remove_suffix(6);
|
|
string outputFile;
|
|
(outputFile = fileName).append(target);
|
|
outputFileContent(outputFile, transpiledString);
|
|
}
|
|
}
|
|
} else {
|
|
cout << "No valid file provided.\n"; goto exitPoint;
|
|
}
|
|
}
|
|
exitPoint:
|
|
return EXIT_SUCCESS;
|
|
}
|