The 'Tape': a string array structure in the ℙ𝕖𝕡 machine.
get, put, ++, --, pop, push, mark, go
The tape is an array of string cells (with memory allocated dynamically), each of which can be read or written, using the workspace buffer. The tape cell array also includes a tape cell pointer, which is usually called the “current cell” .
instructions affecting the current cell of the tape
In the parsing phase of a script, the attributes of different parse tokens are accessed from the tape and combined and manipulated in the workspace buffer, and then stored again in the current cell of the tape. This means that a script which is transforming some input stream may finish with the entire transformed input in the 1st cell of the tape structure. The script can then print out the cell to <stdout> (with get; print;, which allows further processing by other tools in the pipe chain) or else write the contents of the cell to the file 'sav.pp' (with “get; write;” ).
The current cell is also affected by the stack machine commands pop
and push
. The push command increments the tape pointer (current cell)
by 1 (if the workspace is not empty) and the pop command decrements
the tape pointer by one (if the stack is not empty and the current
cell is not the first one in the tape).
This is a simple but powerful mechanism that allows the tape pointer to stay in sync with the stack. After a “push” or “pop” command the tape pointer will be pointing at the correct tape cell for that item on the stack. In some cases, it may be easiest to see how these mechanisms work by running the machine engine in interactive mode (eg: pep -If script inputfile ) and stepping through a script or executing commands at the interactive debug prompt.
The tape pointer is also incremented and decremented by the ++
and
--
commands, and these commands are mainly used during the compilation
phase to access and combine attributes to transform the input into the
desired output.