update: pushed more readable tokens

This commit is contained in:
maix0 2024-09-26 17:37:57 +02:00
parent 06c2d19097
commit 285104a19a
6 changed files with 199 additions and 239 deletions

20
parser/token.py/concat.py Normal file
View file

@ -0,0 +1,20 @@
from ttoken import *
def concat(tokens: list[Token]):
i = 0
out = []
while i < len(tokens):
tok = tokens[i]
if tok.is_word():
word = Token(TokenType.WORD, subtokens=[])
word.subtokens.append(tok)
j = 1
while i + j < len(tokens) and (tokens[i + j]).is_word():
word.subtokens.append(tokens[i + j])
j += 1
i += j
out.append(word)
else:
out.append(tok)
i += 1
return out