Sample programs

Add your own sample programs

The table of sample programs is set up so that you can add your own µOCCAM examples. These need not be very long - between five and ten lines is a good size. Examples can be valid µOCCAM, which a compiler should accept, invalid µOCCAM, which a compiler should reject, or I/O tests: valid programs which when given a specified input should produce a particular output. Try to think up several examples, each one concentrating on a single language feature.

Once you have devised your sample µOCCAM code, here is how to make them available on the course website.

  1. Check that you are on this list of students taking the course. If you are not, please notify me and I shall investigate.

  2. Put your sample µOCCAM code files in the directory /public/cs3/web/ipptests/. For example, the following ones (at least) are already there.

        bad-sequence.reject
        faulty-continuation.reject
        final-comment.accept  
        simple-sequence.accept
        single-declaration.accept
        pipe.io
    

    The suffix .accept indicates valid µOCCAM code, .reject is for invalid code, and .io is an I/O test.

    The access permissions for this directory have been set so that everyone can edit their own files, but not delete those created by anyone else.

  3. For each file, write a brief description of what it does in an accompanying .comment file. One or two lines is quite enough. This description will appear on the web page, and also in the log file generated by the ipp test script. For example, the invalid bad-sequence.reject file has a matching bad-sequence.comment that explains what is wrong.

    For an I/O test, put the required input and expected output in two files, with the suffix .in and .out respectively. The output should include the "==>" markers that the µOCCAM virtual machine produces. For example, pipe.io has pipe.in and pipe.out.

  4. Create a web page <example-name>.shtml for each example. To use the standard format, copy the following text and insert your own values at every occurrence of ZZZ.

    <!--#set var="title"   value=" ZZZ Title of your example " -->
    <!--#set var="program" value=" ZZZ Name of program       " -->
    
    <!--#set var="author_name" value=" ZZZ Your name " -->
    <!--#set var="author_url"  value=" ZZZ URL for your home page " -->
    
    <!--#include virtual="{accept,reject,io}-sample.shtml" -->
    

    For the name of your program, leave out the suffix and just use bad-sequence, final-comment or whatever. If you don't have a home page on the web, you can use mailto:<your-email-address>. For the final include line, choose either accept-sample.shtml, reject-sample.shtml, or io-sample.shtml according to the type of your example.

    Put this file in the same directory, with a .shtml extension. Check that it works: it should be available at http://www.dcs.ed.ac.uk/home/cs3/ipptests/<example-name>.shtml.

  5. Now create a file <your-userid>.html containing the following text, repeated for every example you have. This will give your rows in the table of examples. Again, fill in the ZZZ sections with your own information.

    <tr>
      <td><a href="ZZZexample-name.shtml">ZZZ Test title</a></td> 
      <td>ZZZ Your name</td>
      <td>ZZZ Valid or Invalid or I/O</td>
      <td>ZZZ Brief description of test</td>
    </tr>
    
  6. Make sure that all your files have the correct permissions. That is, so that everyone can read them, but only you can write to them. This includes the µOCCAM code files, the comment files, the web pages for each individual example, and the <your userid>.html file. To make sure the permissions are correct, check them with ls -l | grep $USER; to change things, use chmod.

  7. Now look back at the table of sample programs to see if yours have appeared. You may need to force your browser to reload the page (Alt-R or even Alt-Shift-R under Netscape). Remember, if your cannot see your example pages, probably nobody else can either.

If you have problems with any of this, post your questions to the newsgroup. If you discover something others will need to know to get it to work, post that too.