The whilenot command reads into the workspace buffer characters from the input stream while the peep buffer is not a certain character or characters. This is a “tokenizing” or “lexing” command and allows the input stream to be parsed up to a certain character without reading that character.
The whilenot command does not exit if it reaches the end of the
input-stream (unlike the read
command).
r; [:space:] { d; } whilenot [:space:]; add "\n"; print; clear;
r; [ ] { while [ ]; clear; add "\n"; } print; clear;
The advantage of the first example is that it allows the script to tokenise the input stream into words
The whilenot command cannot automatically ignore escaped characters
like until
does.
read;
"'" {
# be aware that whilenot will stop at \\' and so
# may not parse the whole profound utterance.
whilenot "'"; put; clear;
add "profound.utterance*";
push; .reparse
}
The following are all commands that read the input-stream.