diff --git a/startup.4th b/startup.4th index 9f006f4..c0e86cc 100644 --- a/startup.4th +++ b/startup.4th @@ -1221,6 +1221,10 @@ CREATE EXCEPTION-STACK NULL , : PARSE-AREA ( -- c-addr u ) SOURCE >IN @ /STRING ; +\ Placeholder to be replaced before switching to terminal input +DEFER REFILL +' FALSE ' REFILL DEFER! + ' UTILITY (DEFINITIONS) : PARSE-EMPTY? ( -- flag ) SOURCE NIP >IN @ = ; @@ -1235,17 +1239,16 @@ CREATE EXCEPTION-STACK NULL , : SKIP-SPACES ( "" -- ) BEGIN ▪ PARSE-EMPTY? 0= WHILE ▪ PEEK-CHAR SPACE? WHILE ▪ SKIP-CHAR ▪ REPEAT ; +: ENSURE-NONEMPTY ( -- f=eof ) + BEGIN PARSE-EMPTY? ?0DUP WHILE REFILL 0= ?DUP UNTIL 0= ; + ' FORTH (DEFINITIONS) \ Comments; ignore all characters until the next EOL or ) character, respectively : \ ( "ccc" -- ) IMMEDIATE BEGIN PARSE-EMPTY? 0= WHILE NEXT-CHAR LF = UNTIL ; : ( ( "ccc" -- ) IMMEDIATE - BEGIN PARSE-EMPTY? 0= WHILE NEXT-CHAR [[ CHAR ) ]] = UNTIL ; - -\ Placeholder to be replaced before switching to terminal input -DEFER REFILL -' FALSE ' REFILL DEFER! + BEGIN ENSURE-NONEMPTY WHILE NEXT-CHAR [[ CHAR ) ]] = UNTIL ; \ Skip whitespace; read and return the next word delimited by whitespace \ The delimiting whitespace character is left in the parse area