Clean up a little bit the symbols function
This commit is contained in:
parent
5e7295cf72
commit
75547dbef6
29
src/orig.py
29
src/orig.py
|
@ -51,17 +51,9 @@ def get_symbols(line: str) -> list[str]:
|
|||
i = 0
|
||||
while i < len(line):
|
||||
if line[i] in ['@', '/', '¥']:
|
||||
if inbetween > 0:
|
||||
res.append(line[i])
|
||||
else:
|
||||
res[-1] += line[i]
|
||||
inbetween = 0
|
||||
symbol = line[i]
|
||||
elif line[i:i+3] == '!sd':
|
||||
if inbetween > 0:
|
||||
res.append(line[i:i+3])
|
||||
else:
|
||||
res[-1] += line[i:i+3]
|
||||
inbetween = 0
|
||||
symbol = line[i:i+3]
|
||||
i += 3
|
||||
elif line[i:i+2] in ['!d', '!w', '!s']:
|
||||
x = i
|
||||
|
@ -71,16 +63,21 @@ def get_symbols(line: str) -> list[str]:
|
|||
i += 1
|
||||
continue
|
||||
|
||||
if inbetween > 0:
|
||||
res.append(line[x:i])
|
||||
else:
|
||||
res[-1] += line[x:i]
|
||||
inbetween = 0
|
||||
symbol = line[x:i]
|
||||
break
|
||||
elif line[i] == '!':
|
||||
raise Exception('Unhandled symbol', line)
|
||||
else:
|
||||
else: # It's not a symbol, it's a regular character
|
||||
inbetween += 1
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# Only reaches this if it's a
|
||||
if inbetween > 0:
|
||||
res.append(symbol)
|
||||
else:
|
||||
res[-1] += symbol
|
||||
inbetween = 0
|
||||
|
||||
i += 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue