Guard against word-not-found in sread tokenization
If text.find(word_str, offset) returns -1, use the offset as a fallback.
This commit is contained in:
parent
28a097997c
commit
1bcb83961a
1 changed files with 2 additions and 0 deletions
|
|
@ -670,6 +670,8 @@ class ZCpu:
|
|||
word_str, dict_addr = tokens[i]
|
||||
# Find word position in text
|
||||
pos = text.find(word_str, offset)
|
||||
if pos == -1:
|
||||
pos = offset # fallback: best guess position
|
||||
word_len = len(word_str)
|
||||
base = parse_buffer_addr + 2 + (i * 4)
|
||||
self._memory.write_word(base, dict_addr)
|
||||
|
|
|
|||
Loading…
Reference in a new issue