#include #include using namespace std; #ifndef YBCON_VERSION #define YBCON_VERSION "UNKNOWN" #endif extern string getFileContent(const string& file); extern void setOutputFileContent(const string& language, const string& file, const string& content); extern string parseString(unique_ptr toParse); extern string transpile(string toTranspile, string language); int main(int argc, char* argv[]) { if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << YBCON_VERSION << 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 parsedString = parseString(make_unique(getFileContent(fileName))); const string transpiledString = transpile(parsedString, target); if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n"; setOutputFileContent(target, fileName.erase(fileName.find(".ybcon")) + target, transpiledString); } else cout << "No valid file provided.\n"; return EXIT_SUCCESS; }