Undo literally everything lol

This commit is contained in:
2025-10-16 13:21:27 +11:00
parent 333a1241e8
commit c98f248245
13 changed files with 184 additions and 356 deletions

45
src/preprocess.py Normal file
View File

@@ -0,0 +1,45 @@
class Line:
def __init__(self, keyword: str, argument: str):
self.keyword: str = keyword
self.argument: str = argument
def preprocess(code: str) -> list[Line]:
token : str = ""
keyword : str = ""
tokenise : list[Line] = []
isString : bool = False
isComment : bool = False
isKeyword : bool = True
for i in code:
if i == "\n":
isComment = False
elif i == "#":
isComment = True
elif isComment:
pass
elif i == '"':
isString = not(isString)
token += i
elif isString:
token += i
elif (i == ';') | (i == '{') | (i == '}'):
if i != ';':
token += i
tokenise.append(Line(keyword, token))
token = ''
keyword = ''
isKeyword = True
elif (i != ' '):
if (i == '('):
isKeyword = False
if isKeyword:
keyword += i
else:
token += i
if (i == '='):
isKeyword = False
tokenise.append(Line(keyword, token))
return tokenise