35 lines
1.4 KiB
C++
35 lines
1.4 KiB
C++
#ifndef LUA_HPP
|
|
#define LUA_HPP
|
|
using namespace StandardComponents;
|
|
|
|
struct LuaTarget: Target {
|
|
print_functions_pair printFunctions() final { return make_pair("io.write", "print"); }
|
|
optional_string uniqueLineSeparator() final { return " "; }
|
|
unordered_task_map getTaskMap() final {
|
|
return {
|
|
make_task(Define,
|
|
if (parseComponent.final) output << "local ";
|
|
output << parseComponent.name;
|
|
if (parseComponent.final) output << " <const>"; // TODO Find an alternative to <const> for lua <5.4
|
|
output << " = ";
|
|
transpileTree(parseComponent.content);
|
|
),
|
|
make_task(types::String, stringInterpolation(parseComponent.content, "[[", "]]", "..");),
|
|
make_task(Function,
|
|
output << "function " << parseComponent.name << '(';
|
|
separate_transpileTree(parseComponent.parameters, ", ");
|
|
output << ')';
|
|
if (not parseComponent.empty()) {
|
|
output << separator;
|
|
if (newLines) output << indentation;
|
|
} else output << ' ';
|
|
separate_transpileTree(parseComponent, 1);
|
|
if (not parseComponent.empty()) output << separator;
|
|
output << "end";
|
|
)
|
|
};
|
|
}
|
|
using Target::Target;
|
|
};
|
|
|
|
#endif |