Pep and Nom

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

the ℕ𝕠𝕞 state command

Show the internal state of the ℙ𝕖𝕡 machine at the time that the command is issued.

about

The state command displays the internal state of the pep virtual machine at the time that the command is executed. This is extremely useful for debugging and highly recommended. It even shows coloured output when executed from the ℙ𝕖𝕡 interpreter.

state example


   [:space:] { while [:space:]; put; clear; add "space*"; push; .reparse }
   ![:space:] { whilenot [:space:]; put; clear; add "word*"; push; .reparse }
   clear;
  parse>
   pop;pop;pop;
   "word*space*word*","words*space*word*" {
     state; clear; add "words*"; push; .reparse
   }
   push;push;push;
 

notes

Using the state command is basically a speedy version of invoking a script with the pep interactive debugger which is more powerful but slower. The interactive debugger allows you to step through the ℕ𝕠𝕞 program one instruction at a time and view the state of the pep machine (it also has many other useful commands which may be useful for learning about the ℙ𝕖𝕡 virtual machine ).

debug a script in interactive mode with the -I switch
 pep -Ie 'r;add "/";print;clear;' -i 'abcdef'