Skip to content
><> interpreter extended with debugging capabilities.
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
fish.py

README.md

><>

This is Harpyon's original fish.py implementation, extended with debugging capabilities. Inspiration comes from fishlanguage.com and the debugging functionality offered by the official Hexagony interpreter.

I really like ><>, but lacking a proper way of debugging makes programming in it pretty hard. The online interpreter provides a good start, but still requires to sit trough almost all of the animation, manually pausing at the desired point. Furthermore, it is not guaranteed to be up all the time. This interpreter provides for more functionality when writing ><> programs, without altering the original workings of fish.py. The next sections explain what is added.

Debugging

A debug view prints the program with the last executed instruction in red. Furthermore, it displays

  • the current stack
  • the current output
  • the register
  • the direction of the instruction pointer

whenever they are applicable. There are two main ways to trigger debug views.

Debug mode

When running the interpreter with the --debug flag, a debug view is printed after each instruction is executed. In conjunction with --tick <seconds>, this roughly mimicks the online interpreter.

Breakpoints

A breakpoint can be put on a cell by a backtick `. Each time this cell it executed, a debug view is printed. Output to stdout is resumed normally.

Animation

Using the --play flag, a ><> program can be executed as an animation. This roughly amounts to debugging without debugging information in a Terminal-clearing environment. Try it, it's fun.

Comment section

When writing a ><> program, I like to keep some notes with me such as a pseudocode outline of what it should do, examples of stack manipulation sequences or an explanation of code for PPCG answers. Generally, they can be included in the ><> program without interrupting its functionality, like in the following example from this answer.

:1%:?vr1(?v1n;
     >n;n0<

:                 Duplicate i (need it if i%1 != 0)
 1                Push 1
  %               Pop i and 1, push i%1
   :              Duplicate top of stack because
                  we need one for the if
    ?v            If i%1 != 0 ------------------------,
      r           Reverse stack so that i is TOS      |
       1(?v       If i > 0 (not < 1)                  |
           1n;      Print 1 and Exit                  |
                  Else                                |
        n0<         Print 0 and --,                   |
     >n           Print n <-------|-------------------'
       ;          Exit <----------'

This is a perfectly valid ><> program because the instruction pointer will never get to the comment section. When debugging, however, it is not nice to have the explanation printed each time. Or sometimes we will need vertical wrapping around. To this end, I allowed for a comment section at the bottom of a ><> program.

It is started by double backticks `` as the first to characters on a new line. As soon as these are encountered, the last line is removed and the interpreter stops looking for code. The program

:1%:?vr1(?v1n;
     >n;n0<

``
Here can be anything.

is interpreted as

:1%:?vr1(?v1n;
     >n;n0<

TODO

  • Start debugging from a certain point.
You can’t perform that action at this time.