Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, request, render_template
- app = Flask(__name__, template_folder=' templates')
- class check:
- def check(code):
- #some inits
- #================================
- result = ""
- lines = code.split('\n')
- # \r is in end of each line. broken af.
- for i in range(len(lines)):
- lines[i] = lines[i][:len(lines[i])-1] #takes out last 2
- comma = ',r ,s ,t ,u ,v ,w ,x ,y ,z ,@ ,0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9'
- comma += ',a ,b ,c ,d ,e ,f ,g ,h ,i ,j ,k ,l ,m ,n ,o ,p ,q'
- comma = comma.split(' ')
- codeseg = {
- "parts":["; --------------------------", "; Your code here"],
- "location":0
- }
- dataseg = ["; --------------------------", "; Your variables here"]
- notTabbed = [
- "IDEAL","MODEL small","DATASEG","CODESEG","start:","exit:","END start","STACK 100h",
- "; --------------------------","; Your code here","; Your variables here","END start","END star"
- #end star is there to fix errs. apparently last line is vut by one char.
- ]
- #================================
- print(lines[0])
- for i in range(len(lines)):
- #to check if tabbed
- if (lines[i] in notTabbed) & (("\t" in lines[i]) or (" " in lines[i])) & (";" not in lines[i]):
- result += f"line {i+1} should not be tabbed (Hazaha).<br />"
- if (lines[i] not in notTabbed) & (("\t" not in lines[i]) and (" " not in lines[i])) & (";" not in lines[i]):
- result += f"line {i+1} should be tabbed (Hazaha).<br />"
- if lines[i] == "":
- result += (f'line {i+1} is empty<br />')
- for form in comma:
- if form in lines[i]:
- result += (f'need space after comma in line {i+1}<br />')
- #Checks for CODESEG so I could know where it is at
- if lines[i] == "CODESEG":
- codeseg["location"] = i
- if not (lines[0][0] == ';'):
- result += ("Name not in first line.<br />")
- if not ((lines[codeseg["location"]+4] == lines[codeseg["location"]+6] == codeseg["parts"][0]) & (lines[codeseg["location"]+5] == codeseg["parts"][1])):
- result += ("'your code here' comment missing / is not in the right place.<br />")
- if not "Name not in first line.<br />" in result:
- if not ((lines[5] == lines[7] == dataseg[0]) & (lines[6] == dataseg[1])):
- result += ("'your variables here' comment missing / is not in the right place.<br />")
- else:
- if not ((lines[4] == lines[6] == dataseg[0]) & (lines[5] == dataseg[1])):
- result += ("'your variables here' comment missing / is not in the right place.<br />")
- if result != "":
- result += 'see <a herf="http://bit.ly/baseASM"> the instructions of writing in base format</a>'
- else:
- result = "None! You're good to go!"
- return(result)
- @app.route("/send", methods=["GET", "POST"])
- def send():
- if request.method == "POST":
- code = request.form["code"]
- return render_template("codetest-unst.html", ERRS=check.check(code), COD=code)
- return render_template("index-unst.html")
- if __name__ == "__main__":
- app.run()
Add Comment
Please, Sign In to add comment