debug/dissect - 2-D analyzer for J sentences
dissect executes the sentence you provide, and displays the results in a 2-dimensional format that allows you to probe around.
The interface is a work in progress, currently tied to the grid control. It will become more intuitive when it has been ported to GTK. I am looking for someone skilled in GTK to work on that - tell me if you're interested.
Browse history, source and examples using Trac.
dissect displays what your sentence does, rather than the particular J syntax you used. The primitives that control data routing:
@ @: & &: &. &.: [ ] ~ hook fork ( )
do not display at all, but are implied by the connections of the blocks. Thus, 2 + 5 and 5 +~ (2) will display identically.
Verbs are shown in pink, results in blue, inputs in white. You will notice that in a sentence such as
ds '#@> ''a'';1 2 3'
there seems to be no display for the >. This is because > in this sentence is not a collector, that is, it is not guaranteed that the outputs of different cells can be combined. A verb is recognized as a collector if it has only one cell, or is the last verb in a chain. In the sentence above, # is a collector.
To see the intermediate results for verbs that are not collectors, you need to select a single cell of their inputs. You do this by clicking on the cell, which requests detail for the result of the cell. CTRL-click will request detail for the cell and all cells that contribute to its result.
When detail is requested, you will see the shape of the result, split into frame and result-cell-chape, separated by /, and with * appended if fill was added during framing. If a result is simultaneously the result of several verbs (as in the example above, where the result is the result of both # and #@>), several shapes may be displayed.
Detail also summons forth selectors, which are places that allow you to select a single cell of a result for further analysis. A selector is a bright-green cell flanked by dull-green operand cell(s). Until a selection has been made, the y operand cell shows the frame of the selector. After a selection has been made, the selected operand(s) will be shown, along with the results they produced.
Multiple levels of selection are supported - as many as needed to fully qualify any result.
If your sentence encountered an execution error, detail is requested for all cells that had an error, and the selectors are initialized to point to the cell in error.
Use JAL/Package Manager.
Load debug/dissect addon with the following line:
ds 'yoursentencehere' ds '(1&+@>)"1 ] 2 2 $ ''abc'';''b'';''cd'';0'
This latter example will display something like this:
This shows successive steps of assembling the boxed vector, reshaping it to be a 2 by 2 matrix, and applying rank to specify the vectors of this matrix. The errors occur at the point of attempting to add one to the character "a" - since characters are not in the domain of addition, we get a "domain error" for each attempt.
I am adding support for the computational modifiers of J, such as / and ^:.
When that is finished, I will change the GUI to support GTK, provided that is feasible. I am looking for a collaborator to work on that part while I finish the engine.