49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
|
//
|
||
|
// Created by username404 on 09/01/2021.
|
||
|
//
|
||
|
#include <iostream>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
enum LANGUAGE: unsigned short {LUA=2,JS=3,PY=4};
|
||
|
|
||
|
pair<LANGUAGE, bool> validLanguage(const string& it) {
|
||
|
string languages[3] = {".lua", ".js", ".py"};
|
||
|
LANGUAGE selected;
|
||
|
bool valid = false;
|
||
|
for (unsigned short i = 0; (i < languages->size()); i++) {
|
||
|
if (it == languages[i]) {
|
||
|
selected = static_cast<LANGUAGE>(i + 2);
|
||
|
valid = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
pair<LANGUAGE, bool> result {
|
||
|
selected,
|
||
|
valid
|
||
|
};
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
string transpile(const string& toTranspile, string language)
|
||
|
{
|
||
|
string transpiled;
|
||
|
auto valided = validLanguage(language);
|
||
|
if (valided.second) {
|
||
|
switch (valided.first) {
|
||
|
// TODO Complete this part
|
||
|
case LUA:
|
||
|
break;
|
||
|
case JS:
|
||
|
break;
|
||
|
case PY:
|
||
|
break;
|
||
|
}
|
||
|
transpiled = toTranspile;
|
||
|
// TODO Actually transpile
|
||
|
} else {
|
||
|
cout << '"' << (char) toupper(language.at(1)) << language.erase(0, 2) << "\" is not a valid target.";
|
||
|
exit(1);
|
||
|
}
|
||
|
return transpiled;
|
||
|
}
|