change preprocessor to split lines

This commit is contained in:
Eric Trombly
2020-03-20 11:21:26 -05:00
parent 5fad71e07f
commit 95b7efebbc
3 changed files with 22 additions and 26 deletions

View File

@@ -78,13 +78,11 @@ def insert(filename, docname):
def parse(inputstring):
"parse(inputstring): returns a parsed output string"
print("preprocessing...")
print(inputstring)
PathLog.track(inputstring)
# split the input by line
lines = inputstring.split("\n")
output = ""
output = [] #""
lastcommand = None
print(lines)
for lin in lines:
# remove any leftover trailing and preceding spaces
@@ -96,7 +94,7 @@ def parse(inputstring):
# remove line numbers
lin = lin.split(" ", 1)
if len(lin) >= 1:
lin = lin[1]
lin = lin[1].strip()
else:
continue
@@ -105,7 +103,8 @@ def parse(inputstring):
continue
if lin[0].upper() in ["G", "M"]:
# found a G or M command: we store it
output += lin + "\n"
#output += lin + "\n"
output.append(lin) # + "\n"
last = lin[0].upper()
for c in lin[1:]:
if not c.isdigit():
@@ -115,10 +114,10 @@ def parse(inputstring):
lastcommand = last
elif lastcommand:
# no G or M command: we repeat the last one
output += lastcommand + " " + lin + "\n"
output.append(lastcommand + " " + lin) # + "\n"
print("done preprocessing.")
return output
print(__name__ + " gcode preprocessor loaded.")
print(__name__ + " gcode preprocessor loaded.")