d
This commit is contained in:
4
main.cpp
4
main.cpp
@@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
// L4: Function.
|
// L4: Function.
|
||||||
|
|
||||||
std::map<int, int> memory_generateConstPlayfield(int n) {
|
std::map<int, int> memory_generateConstPlayfield(
|
||||||
|
int n
|
||||||
|
) {
|
||||||
std::map<int, int> idGroups = { };
|
std::map<int, int> idGroups = { };
|
||||||
auto id = 0;
|
auto id = 0;
|
||||||
for (auto gid = 0; gid < n; ++gid) {
|
for (auto gid = 0; gid < n; ++gid) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ def translateStatement(s):
|
|||||||
posRange = ss.find("range(")
|
posRange = ss.find("range(")
|
||||||
posRangeEnd = ss.find("):")
|
posRangeEnd = ss.find("):")
|
||||||
posClosingScope = ss.find("#}")
|
posClosingScope = ss.find("#}")
|
||||||
|
posOpenSquareBracket = ss.find("[")
|
||||||
|
|
||||||
# #} -> }
|
# #} -> }
|
||||||
if posClosingScope != -1:
|
if posClosingScope != -1:
|
||||||
@@ -51,14 +52,15 @@ def translateStatement(s):
|
|||||||
# name = value -> auto name = value
|
# name = value -> auto name = value
|
||||||
if (
|
if (
|
||||||
posColon == -1 and
|
posColon == -1 and
|
||||||
|
posOpenSquareBracket == -1 and
|
||||||
posEqual >= 0
|
posEqual >= 0
|
||||||
):
|
):
|
||||||
name = ss[:posEqual]
|
name = ss[:posEqual]
|
||||||
value = ss[posEqual + len(" = "):]
|
value = ss[posEqual + len(" = "):]
|
||||||
return f"{indentation}auto {name} = {value};"
|
return f"{indentation}auto {name} = {value};"
|
||||||
|
|
||||||
# Unknown. Return as is.
|
# Unknown. Return with semicolon at the end.
|
||||||
return s
|
return f"{s};"
|
||||||
|
|
||||||
def translateType(s):
|
def translateType(s):
|
||||||
# dict[X, Y] -> std::map<X, Y>
|
# dict[X, Y] -> std::map<X, Y>
|
||||||
|
|||||||
Reference in New Issue
Block a user