24 lines
939 B
C++
24 lines
939 B
C++
#ifndef PY_HPP
|
|
#define PY_HPP
|
|
using namespace StandardComponents;
|
|
|
|
struct PyTarget: Target {
|
|
print_functions_pair printFunctions() final { return make_pair("sys.stdout.write", "print"); }
|
|
optional_string uniqueLineSeparator() final { return {}; }
|
|
unordered_task_map getTaskMap() final {
|
|
return {
|
|
make_task(Define, output << parseComponent.name << " = "; transpileTree(parseComponent.content);),
|
|
make_task(types::String, stringInterpolation(R"(""")", parseComponent.content);),
|
|
make_task(Function,
|
|
output << "def " << parseComponent.name << '(';
|
|
separate_transpileTree(parseComponent.parameters, ", ");
|
|
output << "):" << separator << indentation;
|
|
if (parseComponent.empty()) output << "pass";
|
|
separate_transpileTree(parseComponent, 1);
|
|
),
|
|
};
|
|
}
|
|
using Target::Target;
|
|
};
|
|
|
|
#endif |