2020-12-11 22:36:10 +01:00
|
|
|
//
|
|
|
|
// 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) {
|
2021-02-19 15:59:14 +01:00
|
|
|
const string languages[3] = {".lua", ".js", ".py"};
|
2021-02-26 18:49:10 +01:00
|
|
|
LANGUAGE selected = LUA;
|
2020-12-11 22:36:10 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2021-02-26 18:05:01 +01:00
|
|
|
return pair<LANGUAGE, bool>(selected, valid);
|
2020-12-11 22:36:10 +01:00
|
|
|
}
|
2021-03-06 21:58:47 +01:00
|
|
|
#include "src/headers/parsing/ParseComponents.hpp"
|
2020-12-11 22:36:10 +01:00
|
|
|
|
2021-03-04 11:16:59 +01:00
|
|
|
string transpile(ParseTree tree, string language)
|
2020-12-11 22:36:10 +01:00
|
|
|
{
|
2021-03-04 11:16:59 +01:00
|
|
|
string transpiled;
|
2020-12-11 22:36:10 +01:00
|
|
|
auto valided = validLanguage(language);
|
|
|
|
if (valided.second) {
|
|
|
|
switch (valided.first) {
|
|
|
|
// TODO Complete this part
|
|
|
|
case LUA:
|
|
|
|
break;
|
|
|
|
case JS:
|
|
|
|
break;
|
|
|
|
case PY:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// TODO Actually transpile
|
|
|
|
} else {
|
|
|
|
cout << '"' << (char) toupper(language.at(1)) << language.erase(0, 2) << "\" is not a valid target.";
|
|
|
|
exit(1);
|
|
|
|
}
|
2021-03-04 11:16:59 +01:00
|
|
|
return transpiled;
|
2020-12-11 22:36:10 +01:00
|
|
|
}
|