Pep and Nom

home | documentation | examples | translators | download | blog | all blog posts

the ℕ𝕠𝕞 "whilenot" command

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).

print one word per line
 r; [:space:] { d; } whilenot [:space:]; add "\n"; print; clear;

another way to print one word per line
 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

notes

The whilenot command cannot automatically ignore escaped characters like until does.

a trap when parsing text with while


    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
    }
  

see also

The following are all commands that read the input-stream.