Homework 01
Analyzing a Data Description Language

Out: Friday, August 29
Due: Friday, September 5, at 11:59 AM

Background

In order to write a compiler, we need to study the source language in some detail. Programming languages can be quite complex. Sometimes, it's good to practice on a smaller or simpler language first.

This assignment asks you to study a simple data description language and use it to think more deeply about the stages of a compiler that we learned about in Session 1 and Session 2.

Tasks

Study the DOT graph description language that we encountered in Session 1.

There is a lot of documentation on DOT in the world. Here are the three simple sources I'd like you study for this assignment:

If you'd like to learn more about DOT (it's a cool and useful little language!), check out the DOT page at Wikipedia or search for more resources. For this assignment, though, you can limit your study to the three items listed here.

Now, do these tasks:

  1. Use the DOT language to create your own version of this "six stages of the compiler" diagram we saw in Session 1:

    image of a pipeline depicting six stages in a common compiler

    Feel free to create a different layout for the figure, if you prefer.

    To do this, create a plaintext six-stages.dot file with the DOT code you need.
  2. Download Graphviz for your computer and use it to create a graphic from your DOT program. Save your image as a six-stages.png or six-stages.jpg file.

    The Graphviz site offers downloadable binaries for Windows and source directories for Linux and OS X. If you use a Mac and would like to skip the process of building a binary from source, try downloading this zip file and expanding. It's the Mac binary I've been using happily for years.

    If none of these work for you, you can use the command-line Dot compiler available on student.cs.uni.edu.
    Using Dot on student.cs.uni.edu Here are instructions working at a command line in a shell. If you don't know how to do that in your environment, let me know, and we can discuss options.
    1. Copy your six-stages.dot to student:
      scp six-stages.dot [your-catid]@student.cs.uni.edu:
      
    2. Log in to student:
      ssh [your-catid]@student.cs.uni.edu
      
    3. Run the Dot compiler:
      dot six-stages.dot -Tpng > six-stages.png
      
    4. Log out of student:
      <ctrl-d>
      
    5. Copy your six-stages.dot image from student:
      scp [your-catid]@student.cs.uni.edu:six-stages.png .
      
  3. Describe how Graphviz might process DOT programs, in terms of Session 1's six components of a compiler. (This is similar to what I did for a hypothetical compiler working on the two lines of pseudocode in the second half of Session 1.)

    A few questions you might consider as you think about the DOT language and translating it to something else:
    • What output will each stage of the compiler produce?
    • How might different target languages affect how the compiler works?
    • Which parts of the compiler will be relatively easy to write?
    • Which parts will be relatively hard to write?
    Store your description in a plaintext file named six-stages.txt.

I realize that you are just beginning your study of compilers. I will take that into account as I read your analysis. However, as a CS student, you have used at least two different compilers, written programs in at least two different languages, and have one week of reading and lecture under your belt. This is a good time to begin applying what you know to think about a new language.

Two pages is a reasonable length for this analysis. If you really want to write more, let me know. If you really want to write less, you may not be thinking deeply enough about the issues.

Deliverables

By the due time and date, use the course submission system to submit the following files electronically:

six-stages.dot must be a plaintext file.

No hard copy is required.