Initial commit

This commit is contained in:
2025-09-01 20:41:41 +10:00
commit a604b8d5c4
4 changed files with 151 additions and 0 deletions

36
preprocessor.py Normal file
View File

@@ -0,0 +1,36 @@
import token
delimiters = ["=", ">", "<", "+", "-", "*", "/", " "]
def doNothing():
return
def process_line(process: str) -> list[token.Token]:
buf = ""
tokens: list[token.Token] = []
prevEquals = False
for c in process:
if c in delimiters and buf != "":
tokens.append(token.Token(buf))
buf = ""
if prevEquals and c != '=':
tokens.append(token.Token("="))
prevEquals = False
match c:
case '\n':
doNothing()
case ' ':
doNothing()
case '=':
if prevEquals:
prevEquals = False
tokens.append(token.Token(buf))
else:
prevEquals = True
case _:
buf += c
if buf != "":
tokens.append(token.Token(buf))
return tokens