Debugging Varphi Programs
Things Can Go Wrong
Writing Varphi programs is not like writing programs in other languages, since it uses a completely different paradigm. It is very easy to write the wrong state name in the instruction part of a line, or to have incorrect logic somewhere. When things do go wrong, you can debug your code with Varphi.
The Varphi Command-Line Debugger
The Varphi Command-Line Debugger ships with the Varphi interpreter, and can be used by supplying the -d option to vpi . We'll continue to use our running example of the addition program from this section.
Let's run the Varphi program in debug mode. Run the following command
$ <PATH TO vpi> -d add.vpAgain, you should see no output, since you must supply the input tape first. Let's do that:
$ <PATH TO vpi> -d add.vp
111011
State: qDeleteFirstTallyOrHalt
Tape: [{1}]11011
Press ENTER to step...The debugger shows you the current state, as well as some details of the tape. You may notice the square braces [] and curly braces {} . These are explained below:
Square braces
[]around an element of the tape indicate that the head is currently stationed at that tape cell.Curly braces
{}around an element of the tape indicate that this tape cell was the tape cell which held the first tally in the input tape. It can be used as a "reference point" when debugging.
As you can see from the output of the debugger, you can step through the program by pressing ENTER. When the program finishes executing, the output tape will be printed and the debugger will exit.
In case you're interested, here's the whole session output for this debugger run:
Last updated
Was this helpful?

