diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-09-23 20:36:05 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-09-23 20:51:14 -0700 |
| commit | 3b565483d9fbf6454d6d0e79a4e8fe1ae6c9eace (patch) | |
| tree | d31964a8f2f10c66b28ecea7f2c2ccf136fc0e79 /interpret.e | |
| parent | 9806454fbcd9cbb195eb5ef17e0a1d36e06a64f9 (diff) | |
this should be a robust fix for the double-termination issue when compiling Force-Push: yes Change-Id: Ieaacdc232ea7e3036916d81139fc5c5a41087c64
Diffstat (limited to 'interpret.e')
| -rw-r--r-- | interpret.e | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/interpret.e b/interpret.e index 7f839ac..7695d0b 100644 --- a/interpret.e +++ b/interpret.e @@ -179,7 +179,10 @@ drop 0 ; ~ Greater than "z". -~ Okay, this is the big one, the lexer! Wow. +~ Okay, this is the big one, the lexer! Wow. +~ +~ The only way this can ever return a zero-length string is if it hit EOF, +~ and callers can rely on that. ~ ~ (-- stack string occupying multiple words) : word @@ -190,14 +193,21 @@ ~ Skip whitespace. { key dup is-space } { drop } while - ~ Early exit if it's a zero byte. - dup 0 = { drop dropstring 0 exit } if + ~ Early exit if it's an EOF. We leave the accumulated string on the stack; + ~ since we're not in the loop yet, it will be empty and this will function + ~ as the caller's indication we're at EOF. + dup -1 = { drop exit } if accumulate-string { peek dup is-space { drop exit } if - dup { drop exit } unless + + ~ If it's an EOF, exit, leaving the accumulated string on the stack. + ~ It's nonempty, since we're in the loop already, and from the caller's + ~ perspective it's valid input. + dup -1 = { drop exit } if + consume accumulate-string } forever ; |