Pep and Nom

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

the ℙ𝕖𝕡 virtual machine elements (registers etc)

An overview of the elements of the ℙ𝕖𝕡 virtual machine

The file /doc/machine/doc.dir.index.html contains a list of pages in this folder of the documentation for pep/nom. It contains a documentation page for each element of the pep virtual machine

workspace buffer

The workspace is possibly the most important register in the ℙ𝕖𝕡 virtual machine because almost all commands and operations manipulate it.

This is where all “text change” operations within the machine are carried out. It is similar in concept to a register within a “cpu” or to the SED stream editor pattern space. The workspace is affected by (almost?) all commands, for example the command add appends the given text to the workspace*. The buffer is called this because the same terminology is used for the SED stream editor (and it’s function is similar).

the stack or parse stack

The stack can contain grammar parse-tokens or anything else the you want to put into it. You can put parse-tokens into the ℙ𝕖𝕡 stack with the push command and get them out with the pop command. The stack is designed to be automatically synchronised with the tape array.

the tape

The tape is an array of text data which is synchronized with the machine stack using a tape pointer and the pop and push commands which decrement and increment the tape pointer respectively. The tape is manipulated with the get , put and swap commands.

tape-pointer or the current tape cell:

The tape pointer determines the current tape element (or “cell") which” will be used by “get;” and “put;” commands. The tape pointer is incremented with the ++ command and decremented with the -- command. This pointer register will also be incremented or decremented on a successful push or pop command. To be more explicit, if the workspace buffer is not empty then a push command will increment the tape-pointer and if the stack is not empty then a pop command will decrement the tape-pointer. This behaviour of push and pop is very important for maintained the tape and stack in a synchronized state and for making parsing and compiling (more or less) simple.

peep character register

This machine register is not directly manipulable. It contains the next character in the input stream (or <null> or <eof> if the end-of-input has been reached). This register is used by the while and whilenot commands, which read the input stream while the peep register satisfies a given condition.

the accumulator or counter

The counter or “accumulator” is an integer variable which can be incremented with the command a+ , decremented with the command a- , and set to zero with the command zero .

line counter register

This register contains a count of the number of lines encountered so far in the input stream. It is automatically incremented when a newline \n character is encountered (but not a “\r” character). It can be set to zero with the nolines command. Its value can be appended to the workspace buffer with the lines command

character counter

This register contains a count of the number of (hopefully Unicode) characters encountered so far in the input stream. It is automatically incremented when with each character character. It can be set to zero with the nochars command. Its value is appended (as text) to the workspace buffer with the chars command.