strip spaces when tokenizing

Thanks Max Bernstein for reporting this.
This commit is contained in:
Kartik K. Agaram 2021-03-08 17:54:07 -08:00
parent e58980b4c8
commit d124be9cb6
2 changed files with 24 additions and 0 deletions

View File

@ -210,6 +210,29 @@ fn test-run-integer {
check-screen-row screen, 2/y, "=> 1 ", "F - test-run-integer/2"
}
fn test-run-with-spaces {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox sandbox
# type "1"
edit-sandbox sandbox, 0x20/space
edit-sandbox sandbox, 0x31/1
edit-sandbox sandbox, 0x20/space
edit-sandbox sandbox, 0xa/newline
# eval
edit-sandbox sandbox, 0x13/ctrl-s
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
initialize-screen screen, 0x80/width, 0x10/height
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
check-screen-row screen, 0/y, " 1 ", "F - test-run-with-spaces/0"
check-screen-row screen, 1/y, " ", "F - test-run-with-spaces/1"
check-screen-row screen, 2/y, "... ", "F - test-run-with-spaces/2"
check-screen-row screen, 3/y, "=> 1 ", "F - test-run-with-spaces/3"
}
fn test-run-error-invalid-integer {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage

View File

@ -9,6 +9,7 @@ fn tokenize in: (addr gap-buffer), out: (addr stream cell), trace: (addr trace)
var token-storage: cell
var token/edx: (addr cell) <- address token-storage
{
skip-whitespace-from-gap-buffer in
var done?/eax: boolean <- gap-buffer-scan-done? in
compare done?, 0/false
break-if-!=