Further progress

This commit is contained in:
2025-09-01 21:06:05 +10:00
parent a604b8d5c4
commit 5ebf653342
4 changed files with 38 additions and 28 deletions

View File

@@ -2,6 +2,8 @@ import token
delimiters = ["=", ">", "<", "+", "-", "*", "/", " "]
quick_tokens = [">", "<", "+", "-", "*", "/"]
def doNothing():
return
@@ -16,19 +18,25 @@ def process_line(process: str) -> list[token.Token]:
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 c in quick_tokens:
tokens.append(token.Token(c))
if buf != "":
tokens.append(token.Token(buf))
buf = ""
else:
match c:
case '\n':
doNothing()
case ' ':
doNothing()
case '=':
if prevEquals:
prevEquals = False
tokens.append(token.Token("=="))
else:
prevEquals = True
case _:
buf += c
if buf != "":
tokens.append(token.Token(buf))