Pep and Nom

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

the ℕ𝕠𝕞 "unstack" command

Pop the entire stack as a prefix into the workspace.

This may be useful for displaying the state of the stack at the end of parsing or when an error has occurred. I also use this command for debugging after the parse> label.

The code below is very handy for debugging the grammar of a script because it shows you how that grammar tokens are reducing and when.

watch the parse stack reduce with line numbers


  parse>
    add "line "; lines; add " char "; chars; add ": "; print; clear;
    unstack; print; stack; print; clear;
  

notes

I am actually unsure whether the unstack command affects the tape pointer. Logically it should. That is, it should decrement the tape pointer by the same number that the equivalent pop commands would have done. It should be easy enough to look at the translation scripts to see what it’s behaviour is. The same note applies for the stack command.