|
|
@@ -4,12 +4,15 @@ def includes(): |
|
|
|
return """#include <map> |
|
|
|
#include <string> |
|
|
|
#include <vector> |
|
|
|
#include "cli.h" |
|
|
|
#include "cli_Context.h" |
|
|
|
#include "memory.h" |
|
|
|
#include "memory_Context.h" |
|
|
|
#include "shell.h" |
|
|
|
""" |
|
|
|
|
|
|
|
def replaceAnd(s): |
|
|
|
return s.replace("and", "&&") |
|
|
|
return s.replace(" and", " &&") |
|
|
|
|
|
|
|
def replaceAppend(s): |
|
|
|
return s.replace(".append(", ".push_back(") |
|
|
@@ -30,6 +33,9 @@ def replaceLen(s): |
|
|
|
after = s[posEnd + len(")"):] |
|
|
|
return f"{before}{name}.size(){after}" |
|
|
|
|
|
|
|
def replaceOr(s): |
|
|
|
return s.replace(" or", " ||") |
|
|
|
|
|
|
|
def replaceTrue(s): |
|
|
|
return s.replace("True", "true") |
|
|
|
|
|
|
@@ -170,6 +176,7 @@ class CPP: |
|
|
|
for i in range(0, len(self.fn.statements)): |
|
|
|
s = translateStatement(self.fn.statements[i], self) |
|
|
|
s = replaceAnd(s) |
|
|
|
s = replaceOr(s) |
|
|
|
s = replaceAppend(s) |
|
|
|
# Replace len twice to account for double invocation. |
|
|
|
s = replaceLen(s) |
|
|
|