Add better end stripping

This commit is contained in:
Akbar Rahman 2019-01-18 23:19:45 +00:00
parent f46662bc16
commit 46dafcd59b
Signed by: alvierahman90
GPG Key ID: 20609519444A1269

View File

@ -81,13 +81,17 @@ def process(tokens, macros):
if len(token) == 0: if len(token) == 0:
continue continue
# punctuation is ignored so it is stripped till later
# right now only full stops are stripped because I'm lazy # cutting of the end and then adding it back once expanded
# TODO add better end stripping end = []
full_stopped = False token = list(token)
if token[-1] == '.': for index, char in reversed(list(enumerate(token))):
full_stopped = True if not char.isalnum():
token = token[:-1] end.insert(0, token.pop(index))
else:
break
end = ''.join(end)
token = ''.join(token)
# if no macro is found (or if it is not a macro at all, the value # if no macro is found (or if it is not a macro at all, the value
# will not be changed # will not be changed
@ -103,9 +107,8 @@ def process(tokens, macros):
output[line_number][token_number] = upper_check(token, value) output[line_number][token_number] = upper_check(token, value)
# re-adding the full stop/period # re adding what was trimmed off
if full_stopped: output[line_number][token_number] += end
output[line_number][token_number] += '.'
for line_number, line in enumerate(output): for line_number, line in enumerate(output):
output[line_number] = ' '.join(line) output[line_number] = ' '.join(line)