The input code is a subset of OCaml, with the following key points:
Code must be a single OCaml statement (i.e. excludes the trailing ";;")
Pattern matching is not supported
Physical equality is not implemented
Strings are supported only for use with failwith; they cannot be manipulated
The tool does not use static typing: therefore where OCaml would throw an error, it is possible to step through such a program, although undefined behaviour may occur
Code Editor: Functions
Built in functions include:
Arithmetic
+ : int -> int -> int
- : int -> int -> int
/ : int -> int -> int
* : int -> int -> int
mod : int -> int -> int
Boolean
&& : bool -> bool -> bool
|| : bool -> bool -> bool
not : bool -> bool
Comparisons
<= : int -> int -> bool
>= : int -> int -> bool
< : int -> int -> bool
> : int -> int -> bool
= : 'a -> 'a -> bool
<> : int -> int -> bool
== : 'a -> 'a -> bool
!= : 'a -> 'a -> bool
min : int -> int -> int
max : int -> int -> int
Integers
succ : int -> int
pred : int -> int
abs : int -> int
~- : int -> int
~+ : int -> int
Lists
:: (infix): 'a -> 'a list -> 'a list
empty: 'a list -> bool
hd: 'a list -> 'a
tl: 'a list -> 'a list
fold_left: ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
fold_right: ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
Pairs
fst: 'a * 'b -> 'a
snd: 'a * 'b -> 'b
failwith: string -> 'a
Graph: Interactive Mode
In the default interactive mode, nodes provide information about their purpose when clicked.
Orange subgraphs are used to hide functions. When clicked, these can be opened/closed.
The token is the red arrow; this moves around the graph to perform evaluation.
Purple rounded rectangle nodes are for constants.
Contraction nodes are used where terms are referenced by multiple nodes. When clicked, they can be broken/restored.
Graph: Breakpoint Toggle Mode
In the breakpoint toggle mode, nodes can be set or unset as breakpoints when clicked.
A node where the breakpoint has been set
Once a breakpoint is reached, play stops and the play button turns green
Note: breakpoints may become inactive after stepping backwards, and can be enabled using the "Reactivate Breakpoints" button.
Graph: Navigation & Tool Buttons
Below the graph are a number of buttons. These include:
Redraw graph: redraws the current graph
Backwards, play/pause, forwards: these can be used to move in both directions through evaluation
Go to state n: this jumps to the given state (or the last possible state, whichever is first).
Interactive Mode: the default mode, in which subgraphs can be expanded, contraction nodes split, and other nodes can be selected for more information.
Breakpoint Toggle Mode: selecting this option will enter breakpoint mode, to set breakpoints on nodes
Reactivate breakpoints: this button will become active if the user steps backwards (as the current graph no longer represents the state of the abstract machine). Reactivating breakpoints will require recomputing all states up to and including the current state
Download: provides options to download a single or collection of states, either as SVG or DOT (or GIF for multiple states).
Stats: provides charts to show the size of the program (number of nodes) and number of operations changing during evaluation
About
This is a visual debugger tool for a subset of OCaml (including patterns and lists), using a GoI-style abstract machine for evaluation.
The OCaml visual debugger was implemented by Jack Hughes, using the GoI-style abstraction machine implementation by Steven Cheung.
Attributions
Original implementation by Cheung uses: graph-viz-d3-js (MIT license) for generating diagrams, lc-js (MIT license) for parsing, and jQuery & jQuery UI (MIT license)
The OCaml visual debugger uses (in addition to libraries used by the original implementation):
Ohm (MIT license) for parsing (previous versions have used lc-js (MIT license) for parsing)