Михаил Капелько 1 month ago
parent
commit
61433596aa
2 changed files with 7 additions and 3 deletions
  1. +3
    -1
      main.cpp
  2. +4
    -2
      tr-Python-C++/CPP.py

+ 3
- 1
main.cpp View File

@@ -3,7 +3,9 @@

// L4: Function.

std::map<int, int> memory_generateConstPlayfield(int n) {
std::map<int, int> memory_generateConstPlayfield(
int n
) {
std::map<int, int> idGroups = { };
auto id = 0;
for (auto gid = 0; gid < n; ++gid) {


+ 4
- 2
tr-Python-C++/CPP.py View File

@@ -21,6 +21,7 @@ def translateStatement(s):
posRange = ss.find("range(")
posRangeEnd = ss.find("):")
posClosingScope = ss.find("#}")
posOpenSquareBracket = ss.find("[")

# #} -> }
if posClosingScope != -1:
@@ -51,14 +52,15 @@ def translateStatement(s):
# name = value -> auto name = value
if (
posColon == -1 and
posOpenSquareBracket == -1 and
posEqual >= 0
):
name = ss[:posEqual]
value = ss[posEqual + len(" = "):]
return f"{indentation}auto {name} = {value};"

# Unknown. Return as is.
return s
# Unknown. Return with semicolon at the end.
return f"{s};"

def translateType(s):
# dict[X, Y] -> std::map<X, Y>


Loading…
Cancel
Save