Pep & Nom

home | Syntagma | docs | examples | translators | download | journal | blog | all blog posts

When you tell a story, try to have point! "Dumb and dumber"

the nom "while" command

Read the input stream while the peep register contains the given character class .

The 'while' command in the pattern-parse language reads the input stream while the PEP virtual machine peep buffer is any one of the characters or character sets mentioned in the argument. The command is written:

An example "while" command
 while [cdef];

The command takes one argument. This argument may also include character classes as well as literal characters. From example,

 while [:space:];

reads the input stream while the peep buffer is a space character The read characters are appended to the 'workspace' buffer. The while command cannot take a quoted argument ("xxx").

Negation for the character class is currently supported using the whilenot command.

notes

The classes that can be used with the while command are not the same as regular expression classes. The following are acceptable classes



    while [a-z];
    while [xyzabc];
    while [:alnum:];
  

However these cannot be combined (as they could in a standard regular expression). So [abc-p] will only match the set of characters {a,b,c,-,p} rather than a,b and the range c-p. This rule applies to all commands in nom that use classes, including the block class tests. See also classes .

The while command is designed to be used mainly in the tokenising phase of the nom script: that is, it consumes the input stream so that a new parse token can be created and push ed onto the parse stack . And the corresponding text is put into the tape string array .

The [:space:] class will match all white space including newlines. But [:blank:] should match all white-space except newlines. These classes should follow the rules of the ctype.h classes. When a nom script is translated to another language (for example: rust| dart| perl| lua| go | java | javascript| ruby | python| tcl | c ) then these character classes should become unicode-aware if I dare use that term. But this may also depend on the target language and my implementation of the translator for that language.

see also