Visualizing generated decoders

It can be tricky to understand the structure of a decoder by looking at the generated code. The -ascii-dag and -ascii-tree options dump complete listings of decision dags and trees, but it can be difficult to understand these dumps. The toolkit can also generate Icon code that you can use to explore trees, viewing one path at a time. This Icon code, when combined with a suitable main program, can act as a CGI script on the World-Wide Web, and you can explore the trees using your favorite Web browser.

The CGI script provides dual views of each node in the decision tree for each matching statement:

We have an example based on our SPARC disassembler. Here's a fairly simple interior node. Here's an interesting node from a user's matching statement. For subtrees like this, the toolkit should be generating better code than it is. The graph-drawing is by dot.

Setting up your own browser

This section shows how to set things up so you can browse matching statements that you write.

Let's suppose you have a SLED specification called problem.spec, and you've written one or more matching statements in the file problem.m.

  1. Create the Icon file used to describe the matching statements:
    tools -icon-dag problem.icn -matcher problem.m problem.spec
    The writes a description of the generated matchers into problem.icn. You need an experimental version of the toolkit, which supports the -icon-dag option.
  2. Combine this Icon file with the htmltree.icn file supplied with the toolkit distribution, and call the resulting program problem:
    icont -o problem problem.icn htmltree.icn
    (If you want the graphics view, you'll have to install dot from the AT&T graphviz package, and you'll have to edit htmltree.icn to use the appropriate path name.)
  3. Put the resulting executable where it can be executed as a CGI script. You'll probably need help from your friendly local systems administrator. Here's what I had to do at my site, which runs the Apache 1.0.3 server; your mileage may vary:
    1. Put the executable Icon program in the directory /home/nr/public_html/cgi-bin/trees/. The corresponding URL is
    2. The code in htmltree.icn uses the environment variables SERVER_NAME and SCRIPT_NAME to reconstruct the URL. With luck, these will be independent of server. Ha ha.
    3. For some unknown reason, Icon programs won't run as CGI scripts at my site, so I had to wrap things in this shell script:
      export SCRIPT_NAME
      exec /home/nr/public_html/cgi-bin/trees/$tree "$@"
  4. Use the URL to explore the matching statements. You can see matcher for the sample SPARC disassembler at

Visit the Toolkit home page