d
This commit is contained in:
@@ -3,6 +3,9 @@ from Function import *
|
||||
def replaceAnd(s):
|
||||
return s.replace("and", "&&")
|
||||
|
||||
def replaceComment(s):
|
||||
return s.replace("#", "//")
|
||||
|
||||
def replaceLen(s):
|
||||
posLen = s.find("len(")
|
||||
posEnd = s.find(")")
|
||||
|
||||
@@ -9,16 +9,29 @@ def process(FILE_IN):
|
||||
lines_in.append(line.rstrip())
|
||||
|
||||
f = Function()
|
||||
out = ""
|
||||
|
||||
# Parse.
|
||||
for ln in lines_in:
|
||||
ln = ln.rstrip()
|
||||
f.parseLine(ln)
|
||||
|
||||
# Empty line.
|
||||
if ln == "":
|
||||
out += "\n"
|
||||
# Comment.
|
||||
elif (
|
||||
ln.startswith("#") and
|
||||
not f.isBody
|
||||
):
|
||||
out += replaceComment(ln) + "\n"
|
||||
# Function.
|
||||
else:
|
||||
f.parseLine(ln)
|
||||
|
||||
if f.isComplete:
|
||||
print("Function ready! Here it is in C++:")
|
||||
cpp = CPP(f)
|
||||
print(cpp.translate())
|
||||
out += cpp.translate()
|
||||
# Create new function instance.
|
||||
f = Function()
|
||||
|
||||
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user