Add a separate_transpileTree overload and transpile function parameters correctly

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-03-19 12:40:14 +01:00
parent 5f3c8d785d
commit ba14e95d50
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
4 changed files with 10 additions and 6 deletions

View File

@ -106,9 +106,13 @@ protected:
IS(ParseTree)
void separate_transpileTree(const T& parseTree, const unsigned short& indentationLevel = 0) {
transpileTree(parseTree, indentationLevel, [this, &parseTree](const auto& iterator){
if (iterator + 1 != parseTree.cend()) {
output << separator;
}
if (iterator + 1 != parseTree.cend()) { output << separator; }
});
}
IS(ParseTree)
void separate_transpileTree(const T& parseTree, const string_view separation_characters) {
transpileTree(parseTree, 0, [this, &parseTree, &separation_characters](const auto& iterator){
if (iterator + 1 != parseTree.cend()) { output << separation_characters; }
});
}
typedef optional<const char*> optional_string;

View File

@ -13,7 +13,7 @@ struct JsTarget: Target {
make_task(types::String, stringInterpolation(parseComponent.content);),
make_task(Function,
output << "function " << parseComponent.name << '(';
transpileTree(parseComponent.parameters);
separate_transpileTree(parseComponent.parameters, ", ");
output << ") {";
if (newLines) output << separator << indentation;
separate_transpileTree(parseComponent, 1);

View File

@ -17,7 +17,7 @@ struct LuaTarget: Target {
make_task(types::String, stringInterpolation(parseComponent.content, "[[", "]]", "..");),
make_task(Function,
output << "function " << parseComponent.name << '(';
transpileTree(parseComponent.parameters);
separate_transpileTree(parseComponent.parameters, ", ");
output << ')' << separator;
if (newLines) output << indentation;
separate_transpileTree(parseComponent, 1);

View File

@ -11,7 +11,7 @@ struct PyTarget: Target {
make_task(types::String, stringInterpolation(R"(""")", parseComponent.content);),
make_task(Function,
output << "def " << parseComponent.name << '(';
transpileTree(parseComponent.parameters);
separate_transpileTree(parseComponent.parameters, ", ");
output << "):" << separator << indentation;
separate_transpileTree(parseComponent, 1);
),