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
|
i = 0
|
||||||
while i < len(line):
|
while i < len(line):
|
||||||
if line[i] in ['@', '/', '¥']:
|
if line[i] in ['@', '/', '¥']:
|
||||||
if inbetween > 0:
|
symbol = line[i]
|
||||||
res.append(line[i])
|
|
||||||
else:
|
|
||||||
res[-1] += line[i]
|
|
||||||
inbetween = 0
|
|
||||||
elif line[i:i+3] == '!sd':
|
elif line[i:i+3] == '!sd':
|
||||||
if inbetween > 0:
|
symbol = line[i:i+3]
|
||||||
res.append(line[i:i+3])
|
|
||||||
else:
|
|
||||||
res[-1] += line[i:i+3]
|
|
||||||
inbetween = 0
|
|
||||||
i += 3
|
i += 3
|
||||||
elif line[i:i+2] in ['!d', '!w', '!s']:
|
elif line[i:i+2] in ['!d', '!w', '!s']:
|
||||||
x = i
|
x = i
|
||||||
|
@ -71,16 +63,21 @@ def get_symbols(line: str) -> list[str]:
|
||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if inbetween > 0:
|
symbol = line[x:i]
|
||||||
res.append(line[x:i])
|
|
||||||
else:
|
|
||||||
res[-1] += line[x:i]
|
|
||||||
inbetween = 0
|
|
||||||
break
|
break
|
||||||
elif line[i] == '!':
|
elif line[i] == '!':
|
||||||
raise Exception('Unhandled symbol', line)
|
raise Exception('Unhandled symbol', line)
|
||||||
else:
|
else: # It's not a symbol, it's a regular character
|
||||||
inbetween += 1
|
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
|
i += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue