27 lines
1.1 KiB
C++
27 lines
1.1 KiB
C++
#include <iostream>
|
|
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 fileName = (argv[argc - 1] != nullptr) ? argv[argc - 1] : "none" ;
|
|
if (fileName != "none" and fileName.ends_with(".ybcon"))
|
|
{
|
|
bool printResult = false;
|
|
string target = ".lua";
|
|
string currentArg;
|
|
for (signed int i = 0; i < argc; ++i)
|
|
{
|
|
currentArg = ((string) argv[i]);
|
|
if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true;
|
|
else if (currentArg.starts_with("--target=")) target = '.' + currentArg.erase(0, 9);
|
|
}
|
|
const string transpiledString = transpile(parseString(getFileContent(fileName)), target);
|
|
if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n";
|
|
setOutputFileContent(fileName.erase(fileName.find(".ybcon")) + target, transpiledString);
|
|
}
|
|
else cout << "No valid file provided.\n";
|
|
return EXIT_SUCCESS;
|
|
}
|